How to delete periodically_call_remote from the DOM

I have set up a periodically call remote on a page. To get it to stop
calling I have made it reliant on a hidden element being populated
with some value, this is all working.

But I want to actually delete the script from the DOM based on a
decision from the server.

What would be the best way to go about doing this?

Thanks

Regards

Mikel

that should be possible with rjs, shouldnt it?
like that in the controller:
page['updater'].replace ''

<div id="updater"><%= rails updater helper %></div>

Hi Mikel,

Mikel wrote:

I have set up a periodically call remote on a page. To get it to stop
calling I have made it reliant on a hidden element being populated
with some value, this is all working.

But I want to actually delete the script from the DOM based on a
decision from the server.

What would be the best way to go about doing this?

One way to handle it would be to wrap the periodically_call_remote with a <div id="unique_id> and use RJS. Either page.replace or page.replace_html depending on whether you wanted to get rid of the div entirely or just some of what's inside.

hth,
Bill

Mikel wrote:

I have set up a periodically call remote on a page. To get it to stop
calling I have made it reliant on a hidden element being populated
with some value, this is all working.

But I want to actually delete the script from the DOM based on a
decision from the server.

What would be the best way to go about doing this?

One way to handle it would be to wrap the periodically_call_remote with a
<div id="unique_id> and use RJS. Either page.replace or page.replace_html
depending on whether you wanted to get rid of the div entirely or just some
of what's inside.

That won't work because DIV only launches the JavaScript object. This persists in memory for ever and ever.

The fix is to use :condition to detect a JS variable, and then use another Ajax update to set this to false.

Start with this JS:

        keep_polling = true;
...
        <%= periodically_call_remote(
                        :url => {:action => 'slow_thing' },
                        :frequency => 5,
                        :condition => 'keep_polling == true'
                        )
                %>

When the slow_thing finishes, it can use render :update to send 'keep_polling = false'.

Mikel wrote:

I have set up a periodically call remote on a page. To get it to stop
calling I have made it reliant on a hidden element being populated
with some value, this is all working.

But I want to actually delete the script from the DOM based on a
decision from the server.

What would be the best way to go about doing this?

I answered this a couple days ago. Use Google Groups and look for periodically_call_remote and my street name.

Thanks,

Regards

Mikel