Warning: Can't use blame annotator:
svn blame failed on branches/LCSv2/views/generic.load: ("Can't find a temporary directory: Internal error", 20014)

source: tmcsimulator/branches/LCSv2/views/generic.load @ 619

Revision 619, 875 bytes checked in by jdalbey, 6 years ago (diff)

Add branch LCSv2

RevLine 
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.