It couldn't be any easier! Luv that web2py.
Honestly, I had gotten very close to the right answer. My code was using 
response.js='location.reload();' as a temp workaround for my inability to 
reload just the components. But I didn't make the connection that I should 
drill down into the DOM from document to div level.
However, upon trying your line, with and without a semicolon, I keep 
getting Javascript error: jQuery('#grid_course,#grid_pricelist').reload is 
not a function.



On Sunday, June 16, 2013 9:03:35 PM UTC+2, Massimo Di Pierro wrote:
>
> The code in
>
> ###################
>         # RELOAD COMPONENTS grid_course AND grid_pricelist BUT HOW?
>         ###################
>
> should be
>
>         response.js = "jQuery('#grid_course,#grid_pricelist').reload()"
>
> could it be easier?
>
> On Sunday, 16 June 2013 09:59:06 UTC-5, step wrote:
>>
>> In the same page I placed three embedded components, each one with its 
>> own separate .load file which index.html loads with LOAD().
>> 1) form_years, SQLFORM.factory whose controller returns 
>> dict(form_years=form_years)
>> 2) grid_course, SQLFORM.grid whose controller returns 
>> dict(grid_course=grid_course)
>> 3) grid_pricelist, SQLFORM.grid whose controller returns 
>> dict(grid_pricelist=grid_pricelist)
>> The queries in the two SQLFORM.grids depend on variable session.years 
>> which can be set through form_years when the form is accepted.
>>
>> So I want to be able to select a value in form_years, submit it and 
>> automatically update the contents of grid_course and grid_pricelist based 
>> on the new session.years value, without reloading the whole page but just 
>> the affected components (the grids .load files).
>> Everything is coded and is working beautifully, except for the automatic 
>> reloading of the grid components. I tried several methods but I failed. I 
>> don't know how to do it. Is it possible? How?
>>
>> Thanks in advance
>> P:S. This is my first post in the list!
>>
>> Here is an overview of my code:
>> **** Page URL http://127.0.0.1:8000/app/course/index
>>
>> **** Component views
>> ** views/course/index.html
>> {{extend 'layout.html'}}
>> {{=BEAUTIFY(response._vars)}}
>> {{=LOAD(c='course',f='form_year.load',target='form_year',ajax=True,
>> content=P(T('loading...')))}}
>> {{=LOAD(c='course',f='grid_course.load',target='grid_course',ajax=True,
>> content='')}}
>> {{=LOAD(c='course',f='grid_pricelist.load',target='grid_pricelist',ajax=
>> True,content='')}}
>> {{pass}}
>> {{if request.is_local:}}
>> {{=response.toolbar()}}
>> {{pass}}
>>
>> ** views/course/form_year.load
>> {{pass}}
>> {{=form_year}}
>>
>> ** views/course/grid_course.load
>> {{pass}}
>> {{=grid_course}}
>>
>> ** views/course/grid_pricelist.load
>> {{pass}}
>> {{=grid_pricelist}}
>>
>> **** Controllers
>> ** controllers/course.py
>> # -*- coding: utf-8 -*-
>>
>> def index():
>>     return dict()
>>
>> #@auth.requires_login()
>> def form_year():
>>     form_year = SQLFORM.factory(Field('years'),table_name='form_year')
>>     if form_year.process().accepted:
>>         session.years = form_year.vars.years
>>         ###################
>>         # RELOAD COMPONENTS grid_course AND grid_pricelist BUT HOW?
>>         ###################
>>     elif form_year.errors:
>>         response.flash = 'form_year has errors'
>>     return dict(form_year=form_year)
>>
>> #@auth.requires_login()
>> def grid_course():
>>     grid_course = SQLFORM.grid(
>>         query_from(db.course.year, session,years()),
>>         formname='grid_course')
>>     return dict(grid_course=grid_course)
>>
>> #@auth.requires_login()
>> def grid_pricelist():
>>     grid_pricelist = SQLFORM.grid(
>>         query_from(db.pricelist.year, session.years),
>>         formname='grid_pricelist')
>>     return dict(grid_pricelist=grid_pricelist)
>>
>> def query_from(field, integers)
>>     """
>>     builds a DAL query for "field in integers"
>>     """
>>     pass
>>
>>
>>

-- 

--- 
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/groups/opt_out.


Reply via email to