Hi,
I try to do exactly the same and have the following in my app:
controller:
def index():
response.js = '$.web2py.component("%s", target="graph1");' %
URL('default', 'graph1.load')
index.html:
<div id="graph1" style="width: 400px; height: 400px; margin: 0 auto">
</div>
graph1.load contains a graph in pure JS
What am I overlooking?
KInd regards
On Tuesday, January 21, 2014 5:15:17 PM UTC+1, Anthony wrote:
>
> You could put both the form and the grid in ajax components. When the form
> is submitted, it could send back a JS command to load the grid:
>
> In index.html:
>
> {{=LOAD('default', 'tracker_form.load', ajax=True)}}
> <div id='content_grid'></div>
>
> Change your two existing views to a .load extension (not required, but
> done by convention for component views), and remove the {{extend
> 'layout.html'}} from each.
>
> In tracker_form, do:
>
> if form.process().accepted:
> response.js = '$.web2py.component("%s", target="content_grid");' %
> URL('default', 'show_form.load')
> response.flash = 'Submitted Successfully!'
>
> Whenever the form is submitted and accepted, it will reload the grid in
> the "content_grid" div.
>
> Anthony
>
> On Tuesday, January 21, 2014 10:37:04 AM UTC-5, En Ware wrote:
>>
>> Hello,
>>
>> I am trying to figure out how to call more then function per view.
>> I would like to be to have users fill out a form and and then as soon as
>> they submit
>> show the results sort of like SQLFORM. I also want to make the "grid"
>> editable so
>> that users can hide rows and columns.
>>
>> Thanks in Advance.
>>
>>
>>
>> #controller default.py
>>
>> def index():
>> return dict()
>>
>>
>> def tracker_form():
>> record = db.content(request.args(0))
>> show_record = request.args(0)
>> form = SQLFORM(db.content, record, show_record)
>> if form.process().accepted:
>> response.flash = 'Submitted Successfully!'
>> #response.view = 'http://127.0.0.1:8000/WnD/default/show_form'
>> #return dict(show_record=show_record)
>> elif form.errors:
>> response.flash = 'Form is not correct; please correct and submit
>> again'
>> else:
>> response.flash = 'Please fill out the damn form'
>> return dict(form=form)
>>
>>
>>
>> def show_form():
>> #rows = db().select(db.content.ALL)
>> return dict(grid=SQLFORM.grid(db.content))
>>
>>
>>
>>
>>
>> #views
>>
>> #tracker_form.html
>>
>> {{extend 'layout.html'}}
>> <h4><center>Tracking</center></h4>
>> {{=form}}
>> {{=BEAUTIFY(request.vars)}}
>>
>>
>> #show_form.html
>>
>> {{extend 'layout.html'}}
>> <h4><center>Records processed</center></h4>
>>
>> {{=grid}}
>>
>> <a href="http://127.0.0.1:8000/WnD/default/tracker_form">Back</a>
>>
>>
>> #index.html
>>
>> {{extend 'layout.html'}}
>> <title>Watch and Defend</title>
>> <h4>
>> Current customers:
>> </h4>
>> <H4>
>>
>>
>> <a href=http://127.0.0.1:8000/WnD/default/tracker_form><center>Tracker
>> Monitoring click on the link</a></center>
>>
>> </H4>
>>
>>
>>
>>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.