Hello Anthony in order to do what you propose here, I mean passing javascript code from the controller to the view by mean of return dict(var=js), I think the only way I have to execute the passed js code is to use eval in the view like this :
<script type="text/javascript"> eval({{=var}}); </script> Now, my concern is, is that secure to use javascript eval(); in this way and is what you have in mind when you make this proposition? Thanks Richard On Sun, Jun 5, 2011 at 7:43 PM, Anthony <abasta...@gmail.com> wrote: > Can't you just include the relevant JS directly in the view template for > the page, or maybe include the JS string in the dict returned by the > controller, and insert it as a variable in the view? > > On Sunday, June 5, 2011 6:22:13 PM UTC-4, David J wrote: > >> How do I inject javascript in my controller from a regular web request? >> >> I read the docs it syas response.js is executed only in a component; >> >> so I have a form and I would like to add JS validators. >> >> so I try adding to the response.js = '$("myfield").validate("**digits");' >> >> >> Of course this only works in component mode as I tried it; >> >> But now I have a single form page and I want this same javascript to >> work; >> >> How do I do that? >> >> Thanks. >> >> >> --