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 <chan...@wso2.com> wrote: > Hi Shan, > > Cool thing.. Thanks for the info. > > Regards, > Chanaka > > On Mon, Dec 19, 2016 at 1:33 PM, Shan Mahanama <sh...@wso2.com> 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 <chan...@wso2.com> >> 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: chan...@wso2.com; cell: +94 77 4464006 <+94%2077%20446%204006> >>> blog: http://chanaka3d.blogspot.com >>> >>> _______________________________________________ >>> Dev mailing list >>> Dev@wso2.org >>> 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: sh...@wso2.com >> Mobile: +94 71 2000 498 >> >> >> > > > -- > Chanaka Jayasena > Associate Tech Lead, > email: chan...@wso2.com; cell: +94 77 4464006 <+94%2077%20446%204006> > blog: http://chanaka3d.blogspot.com > -- Chanaka Jayasena Associate Tech Lead, email: chan...@wso2.com; cell: +94 77 4464006 blog: http://chanaka3d.blogspot.com
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev