Home General Discussion

Portal customization - how can I include another .js file from CustomSpace

I want to add a second .js file to my CustomSpace that will sit alongside custom.js. How would I tell Cireson to include this file?

Best Answer

Answers

  • Dann_MichelsonDann_Michelson Customer IT Monkey ✭
    I think that'll work. It would be great if I could add it without feeling like I'm using a "backdoor" method but this will do it.

    I'd almost setup gulp to compile and minify into custom.js instead of that being the source code itself...
  • Eugene_RackEugene_Rack Customer Adept IT Monkey ✭✭
    Thanx for information. If using that code in the custom.js to call another.js, is there a way to only call the another.js if the session user is an analyst?
  • Martin_BlomgrenMartin_Blomgren Customer Ninja IT Monkey ✭✭✭✭
    @Eugene_Rack, use the global variable session.user.Analyst

    For example at the top of in your another.js:
    if (session.user.Analyst === 0) {<br>&nbsp;&nbsp;&nbsp; return;<br>}


    Or in custom.js when loading your another.js:
    if (session.user.Analyst === 1) {<br>&nbsp;&nbsp;&nbsp; $.getScript("/CustomSpace/another.js");<br>}


  • Martin_BlomgrenMartin_Blomgren Customer Ninja IT Monkey ✭✭✭✭
    @Eugene_Rack, use the global variable session.user.Analyst


    @Eugene_Rack, answering here instead of PM in case someone else is hitting the same problem.
    Please note that the global session variable isn't available before the DOM is loaded so make to wait for it to be ready!
    $(document).ready(function (){<br>&nbsp;&nbsp;&nbsp; if (session.user.Analyst === 1) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $.getScript("/CustomSpace/another.js");<br>&nbsp;&nbsp;&nbsp; }<br>});

  • Eugene_RackEugene_Rack Customer Adept IT Monkey ✭✭
    Hello Martin

    Thanx very much for the reply. Working perfectly. Thanx for all your help looking into this.

    Kind regards
    Eugene
Sign In or Register to comment.