On Apr 1, 6:30 pm, Steve Shephed <[email protected]> wrote:
> Fantastic
> But where do i put it in say the Welcome example application.
> I am new to web2py but really like the concepts I have learned so far.

The example below would go in a controller (for example default.py).
Then click on "index" to try.

If people like this, something like this could be standard in the
helpers.

class Partial(DIV):
    def __init__(self,anchor,callback):
        DIV.__init__(self)
        import random
        target="target"+str(random.random())[2:]
        script="$('#%s').load('%s',{},function(r,t,c){try{d=eval('('+r
+')');window.location=d['url']}catch(e){};})" % (target,URL
(r=request,f=callback))
        self.components=[TAG.BUTTON(anchor,_onclick=script),DIV
(_id=target)]
    @staticmethod
    def redirect(url):
        import gluon.contrib.simplejson as sj
        return sj.dumps({'url':url})

def index():
    return dict(partial1=Partial('click me for text','mycallback1'),
                partial2=Partial('click me to
redirect','mycallback2'))

def other():
    return dict(message='Other')

def mycallback1():
    return 'hello world'

def mycallback2():
    session.flash="you have been redirected here"
    return Partial.redirect(URL(r=request,f='other'))
--~--~---------~--~----~------------~-------~--~----~
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