source: OpenRLabs-Git/deploy/rlabs-docker/web2py-rlabs/applications/welcome/views/generic.load

main
Last change on this file was 42bd667, checked in by David Fuertes <dfuertes@…>, 4 years ago

Historial Limpio

  • Property mode set to 100755
File size: 875 bytes
Line 
1{{'''
2# License: Public Domain
3# Author: Iceberg at 21cn dot com
4
5With this generic.load file, you can use same function to serve two purposes.
6
7= regular action
8- ajax callback (when called with .load)
9
10Example modified from http://www.web2py.com/AlterEgo/default/show/252:
11
12def index():
13    return dict(
14                part1='hello world',
15                part2=LOAD(url=URL(r=request,f='auxiliary.load'),ajax=True))
16
17def auxiliary():
18    form=SQLFORM.factory(Field('name'))
19    if form.accepts(request.vars):
20        response.flash = 'ok'
21        return dict(message="Hello %s" % form.vars.name)
22    return dict(form=form)
23
24Notice:
25
26- no need to set response.headers['web2py-response-flash']
27- no need to return a string
28even if the function is called via ajax.
29
30'''}}{{if len(response._vars)==1:}}{{=response._vars[next(iter(response._vars))]}}{{else:}}{{=BEAUTIFY(response._vars)}}{{pass}}
Note: See TracBrowser for help on using the repository browser.