Most of the time, cliet-side JSs are executed after DOM is fully loaded (means in the document.ready() function). That's why 'sendToClient' puts the variable in the bottom-js position. So, if you are dong DOM manipulations in your JSs, please do them in document.ready().
Anyway, I think "sendToClient' should give the option to push a variable to the 'head JS'. Can you create an issue for this in carbon-uuf repo? Thanks. On Fri, Dec 23, 2016 at 3:34 PM, Chanaka Jayasena <[email protected]> wrote: > Hi, > > The "sendToClient" method is injecting the variables to the "js" > placeholder in the layout. We have the "js" placeholder near the end of the > page. When we try to access a variable from a js method that is defined > before the sendToClient variable injections, it is giving errors. We can > workaround this problem by wrapping our method calls inside document ready > method. > > But as an improvement to the "sendToClient" method can we injection the > variables to the header section of the page without depending on the > placeholder. If that is not possible then prepending to the headJs will > make the variables available to all the other scripts. > > thanks, > Chanaka > > > > On Mon, Dec 19, 2016 at 1:42 PM, Chanaka Jayasena <[email protected]> > wrote: > >> Hi Shan, >> >> Cool thing.. Thanks for the info. >> >> Regards, >> Chanaka >> >> On Mon, Dec 19, 2016 at 1:33 PM, Shan Mahanama <[email protected]> wrote: >> >>> Hi Chanaka, >>> >>> We can send the app context from the server side to client side using >>> *sendToClient >>> *function. You can use *sendToClient* function inside the *onRequest* >>> function like this. >>> >>> function onRequest(env) { >>> sendToClient("contextPath", env.contextPath); >>> } >>> >>> >>> Then the *contextPath* variable will be added at the end of the html body >>> like below and then you can get the app context in the client side using >>> *contextPath* variable. >>> >>> <script type="text/javascript">var contextPath="/test";</script> >>> >>> Thanks, >>> Shan. >>> >>> >>> On Mon, Dec 19, 2016 at 12:08 PM, Chanaka Jayasena <[email protected]> >>> wrote: >>> >>>> Hi guys, >>>> >>>> We are doing the routing from the client side. So we want to read the >>>> app context from javascript. Is there a nice way to do this without adding >>>> a <script> var context = '{{@config.context}}'; </script>? >>>> >>>> It the @config is available in the client side it will be a nice >>>> feature addition to UUF. >>>> >>>> thanks, >>>> Chanaka >>>> >>>> -- >>>> Chanaka Jayasena >>>> Associate Tech Lead, >>>> email: [email protected]; cell: +94 77 4464006 <+94%2077%20446%204006> >>>> blog: http://chanaka3d.blogspot.com >>>> >>>> _______________________________________________ >>>> Dev mailing list >>>> [email protected] >>>> http://wso2.org/cgi-bin/mailman/listinfo/dev >>>> >>>> >>> >>> >>> -- >>> Shan Mahanama >>> >>> Software Engineer, WSO2 Inc. http://wso2.com >>> <http://l.facebook.com/l.php?u=http%3A%2F%2Fwso2.com&h=gAQEswASa> >>> Email: [email protected] >>> Mobile: +94 71 2000 498 >>> >>> >>> >> >> >> -- >> Chanaka Jayasena >> Associate Tech Lead, >> email: [email protected]; cell: +94 77 4464006 <+94%2077%20446%204006> >> blog: http://chanaka3d.blogspot.com >> > > > > -- > Chanaka Jayasena > Associate Tech Lead, > email: [email protected]; cell: +94 77 4464006 <+94%2077%20446%204006> > blog: http://chanaka3d.blogspot.com > > _______________________________________________ > Dev mailing list > [email protected] > http://wso2.org/cgi-bin/mailman/listinfo/dev > > -- Sajith Janaprasad Ariyarathna Software Engineer; WSO2, Inc.; http://wso2.com/ <https://wso2.com/signature>
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
