Thanks, links are always trapped now. Works great. 

Matt

On Saturday, August 3, 2013 5:14:49 AM UTC-7, Niphlod wrote:
>
> you need to use web2y.js's component() function to have the same behaviour 
> of the standard LOAD().
> You're using jQuery.load() that is the jquery default way to replace an 
> html element with something retrieved by the server, but it doesn't add all 
> the bits that are needed to trap the links, for example.
>
> However, what you're trying to do (reload a component every n seconds) is 
> right built into the LOAD() helper.
> Use it this way:
>
> LOAD('default', 'thisgrid.load', ajax=True, target='mydiv', timeout=30000, 
> times='Infinity')
>
> if you still need to use the function to load something "on demand", the 
> js signature of the component() function is:
>
> $.web2py.component(remote, target, timeout, times [, element])
>
> in your case, $.web2py.component('/appname/default/thisgrid.load', 
> 'mydiv', 30000, 'Infinity')
>
> With the new  web2py.js, however, you can just have the same functionality 
> just creating a DIV with the proper  data- attributes (this is what LOAD() 
> does)...
>
> DIV(_id="mydiv", data=dict(w2p_remote=URL('default', 'thisgrid.load'), 
> w2p_times='Infinity', w2p_timeout=30000)) 
>
> On Saturday, August 3, 2013 4:10:49 AM UTC+2, Matt Grham wrote:
>>
>> Thanks a lot Niphlod. Actually that was the case. I started to use 
>> web2py 2.4.6 but my app was built using web2py 1.99.7. I updated web2py.js, 
>> web2py_ajax.html and layout.html. It works now. But if I want to refresh 
>> the component in every 30 seconds, I am having a problem. Sometimes 
>> pagination links or sorting links are not trapped. How can I refresh the 
>> component properly?
>>
>> The following helps to refresh, but links are not trapped in some cases. 
>>
>> in container.html:
>>
>> {{extend 'layout.html'}}
>>
>> {{=frag}}
>>
>> <script>
>> jQuery(document).ready(function(){
>> var auto_refresh = setInterval(
>> function()
>> {
>> $('#mydiv').load('{{=URL(r=request,c='default',f='thisgrid.load' )}}'); 
>> }, 30000);
>> });
>> </script>
>>
>> in controller (target is added):
>>
>> def container():
>>     frag = LOAD('default', 'thisgrid.load', ajax=True, target='mydiv')
>>     return dict(frag=frag)
>>
>>
>> On Friday, August 2, 2013 1:24:22 PM UTC-7, Niphlod wrote:
>>>
>>> did you start with an old (pre 2.6.0) app and updated web2py ? if yes, 
>>> you need to overwrite your app's web2py.js with welcome/static/web2py.js
>>> I think that the most straightforward example is (assuming working on 
>>> localhost, hence having generic views enabled): take your welcome, put this 
>>> in default.py
>>>
>>> def thisgrid():
>>>     grid = SQLFORM.grid(db.your_table, paginate=5) #paginate defaults 
>>> altered just to avoid having a huge test table filled for this test
>>>     return dict(grid=grid)
>>>
>>> def container():
>>>     frag = LOAD('default', 'thisgrid.load', ajax=True)
>>>     return dict(frag=frag)
>>>
>>>
>>> then access the container page.
>>>
>>

-- 

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