Thanks Anthony!! I resolved my problem with an ajaxSuccess event handler.
I am calling a web2py_component with the target div and using setTimeout to 
achieve what I want. The code snippet in demo/f1.html is below for anyone 
who may be interested:

<script>
my_url = "{{=URL('demo', 'f1.load')}}";
update_interval = 15000;

$(document).ready(function(){
    setInterval(function(){
            web2py_component(my_url, 'content');
    }, update_interval);

    $(document).ajaxSuccess(function(e, xhr, settings) {
        my_url = settings.url;
    });
});
</script>

{{=LOAD('demo', 'f1.load', ajax=True, ajax_trap=True, content='Loading...', 
user_signature=True, target='content')}}

On Wednesday, August 2, 2017 at 6:58:59 PM UTC-7, Anthony wrote:
>
> I have an alert to verify that the data-w2p_remote is set correctly but 
>> the XHR is still made to the default page.
>> Is there some sort of a trigger or a function that I can call that lets 
>> the code in web2py.js know that the URL in the data-w2p_remote attribute 
>> was changed?
>> That would resolve my problem!!
>>
>
> No, that approach won't work, as the data-w2p_remote value is read only 
> once when the parent page is first loaded. Also, if all you want to be able 
> to do is set a custom id for the component div, there is no reason to 
> construct it manually -- just use the "target" argument to load:
>
> LOAD(..., target='mycontent')
>
> As I suggested, you'll have to set up an event handler to monitor 
> completed Ajax requests. You can detect Ajax requests related to the 
> component because they will include a special request header called 
> "web2py-component-element" whose value will match the id of the component 
> div (i.e., the value set as the "target" argument to LOAD). When you detect 
> such a request, grab its URL and set that as the URL to be reloaded every 
> 10 seconds. You'll need to set up your own reloading code, as you will not 
> be able to use the built-in reloading functionality (which can only reload 
> the original data-w2p_remote URL).
>
> Anthony
>

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

Reply via email to