web2py 1.99.4

plugin controller:
def overview():
    if len(request.args) > 0 and request.args[0] == 'refresh':
        import time
        time.sleep(4)
    body = H2('Component header')
    refresh = DIV(A('Refresh', _class='button replacewloading', 
_href=URL(c='plugin_test', f='overview.load', args=['refresh']), 
cid=request.cid))
    
    request.js = '''<script>$(function() 
{$(".replacewloading").click(function() {$(this).parent().html('<span><img 
src="static/plugin_test/images/loading.gif"/>Refreshing...</span>')} );} 
);</script>'''
    
    return dict(body=body, refresh=refresh)

plugin view:
{{=body}}
{{=refresh}}

application view:
{{extend 'layout.html'}}
{{=LOAD('plugin_test', 'overview.load', ajax=True)}}

Reply via email to