I have this problem in a Pylons applicaition I'm converting to Pyrmaid. Right now I'm leaving the Javascript in place, but I'm thinking about moving it to separate templates (not static files). Then I can inject variables without having the Javascript mixed with the HTML. It'll work if it doesn't need any request-specific data, or if all the data can be passed as a few query parameters or is in the session. That should cover most of my use cases but I'm not sure if it'll cover all of them; I'm waiting till I convert the rest of the application to tell.
On Fri, Oct 26, 2012 at 8:49 AM, Jonathan Vanasco <[email protected]> wrote: > If i understand you correctly: > > Before Editing : > Your javascript was embedded in mako. and you had variables set in > javascript > After Editing : > Your javascript is outside of mako, and you need to set variables > > If that is your problem, the solution is to re-architect your > javascript so you can set variables in mako but call functions in a > static file. > > static.js > var MyApp = { > _variable1 : false , > _variable2 : false , > doSomething : function(){ }, > doSomthingElse : function(input){ }, > flashMessage : function(message){ alert('message') }, > } > > dynamic.mako : > <script type="text/javascript"> > $(document).ready(function(){ > MyApp._variable1 = ${a}; > MyApp._variable2 = ${b}; > MyApp.doSomething(); > MyApp.doSomethingElse('${c}'); > MyApp.flashMessage('${hello}'); > }) > </script> > > -- > You received this message because you are subscribed to the Google Groups > "pylons-discuss" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/pylons-discuss?hl=en. > -- Mike Orr <[email protected]> -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
