Some clarifications.
Right now one can already do this in views by inserting somewhere:

<script>
$(document).ready(function() { do_something(); });
</script>

Mr. Freeze's suggestions has pros and cons. In my opinion:

Pros:
  - it is more compact
Cons:
   - moves into the controller something that (usually) belongs to the
view.
   - if the script in quotes has a bug it may break web2py_ajax
because everything would go in the same $(..).ready(function(){}).

I would like to hear more opinions about this. Perhaps some examples
when this would be better than placing the code in the view.

Massimo


On Mar 29, 10:46 pm, Jason Brower <[email protected]> wrote:
> Good question.
> I like the idea as it gives us a nice place to put scripts and make them
> apply to the views we want very easily. so +1 on that!
> Regards,
> Jason Brower
>
> On Sun, 2009-03-29 at 20:23 -0700, mr.freeze wrote:
> > It's basically a new global list, response.scripts, that is rendered
> > in the jQuery(document).ready function so you can inject javascript
> > from the controller.  Massimo mentioned that it may go against MVC
> > separation standards and wanted me to put it out here to get a few
> > opinions.  Sample usage:
>
> > def index():
> >     if not request.vars.name:
> >         response.scripts.append("$('#messages').text('Messages: Name
> > Missing').css('color','red');")
> >     else:
> >         response.scripts.append("$('#messages').text('Messages: Hello
> > " + request.vars.name + "');")
> >     return dict()
>
> > What do you think?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to