I'm really liking this idea Massimo, I'm going to be using it in a
project I'm about to start and grow on it :)

Keeps using ajax very DRY.

On Apr 3, 4:08 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
> There has been a lot of discussion in the past about forms that submit
> via ajax and may or may not refresh the entire page. It is also useful
> to be able to break html pages into "modules" or "plugins" or
> "components" each with its own model, view, controller in such a way
> that they communicate both serversize (by sharing session and
> database) and clientsize (one boxed component should be able for
> example to refresh the entire page or trigger a flash).
>
> I have prototype application that does this.
>
>    http://www.web2py.com/examples/static/web2py.app.events.tar
>
> It uses jquery publisher subscriber mechanism. All the code is in a
> new web2py_ajax and a class call jDiv (similar to Rails Partial but
> more powerful in my opinion) which I could include in html.py
>
> It allows you to write code like this:
>
> def index():
>    return dict(partial1=jDiv('click me for text','mycallback1'),
>                partial2=jDiv('click me for flash','mycallback2'),
>                partial3=jDiv('click me to redirect','mycallback3'),
>                partial4=jDiv('click me for form','mycallback4'))
>
> def mycallback1():
>    return 'hello world'
>
> def mycallback2():
>    return jDiv.flash('this is a test') # flash on the container page
>
> def mycallback3():
>    return jDiv.redirect('http://www.yahoo.com') # redirects entire
> page
>
> def mycallback4():
>    form=FORM('your name:',
>              INPUT(_name='name',requires=IS_NOT_EMPTY()),
>              INPUT(_type='submit'))
>    if form.accepts(request.vars):
>        return jDiv.flash('hello '+form.vars.name)
>    return form
>
> Can you figure out what it does?
> Not that the page is never reloaded. Only parts (partials, jDivs) of
> the reloaded. Each jDiv lives in its own container, has one action,
> can have a view, and can talk to each other.
>
> This may require some more thought.
>
> Comments?
>
> Massimo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to