I find this object (response.scripts) very useful, especially if it's
able to manipulate different HTML elements, not only after page load
(__call__ modification?):
response.scripts("$('#post')", "onclick", "$('#post .comments').css
({'value', 'sm.th.'})")
Probably this breaks the MVC views' rules, but in when it comes to
Ajax I feel more comfortable when the presentation logic is in the
controller.
On Mar 30, 8:18 am, TheDude <[email protected]> wrote:
> This certainly breaks the MVC architecture, but it is valuable. I
> think web2py should be about being able to expand as much as possible
> without interfering the people who just want a small and easy
> framework (it can be a small plant or a big tree). I do like the idea
> of everything going into the same $().ready() function.
>
> After a bit of thinking about it, this would be no different (in terms
> of usability and mvc structure) as saying something like
> response.title = 'xxx' within the controller. I'm going to give this a
> thumbs up, as long as it doesn't slow down the framework and I wont be
> required to do it. ;)
>
> On Mar 30, 12:15 am, mdipierro <[email protected]> wrote:
>
>
>
> > 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
-~----------~----~----~----~------~----~------~--~---