mainqndtest
v1.1.1
Last change
on this file since 42095c5 was
42bd667,
checked in by David Fuertes <dfuertes@…>, 4 years ago
|
Historial Limpio
|
-
Property mode set to
100755
|
File size:
875 bytes
|
Rev | Line | |
---|
[42bd667] | 1 | {{''' |
---|
| 2 | # License: Public Domain |
---|
| 3 | # Author: Iceberg at 21cn dot com |
---|
| 4 | |
---|
| 5 | With 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 | |
---|
| 10 | Example modified from http://www.web2py.com/AlterEgo/default/show/252: |
---|
| 11 | |
---|
| 12 | def index(): |
---|
| 13 | return dict( |
---|
| 14 | part1='hello world', |
---|
| 15 | part2=LOAD(url=URL(r=request,f='auxiliary.load'),ajax=True)) |
---|
| 16 | |
---|
| 17 | def 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 | |
---|
| 24 | Notice: |
---|
| 25 | |
---|
| 26 | - no need to set response.headers['web2py-response-flash'] |
---|
| 27 | - no need to return a string |
---|
| 28 | even 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.