stuck on an rjs thing

hey all,
I'm trying to replace the content of a span with "update ok" text.
That is my view :

<%= link_to_remote 'update', :update => 'updatespan',
     :url => { :action => 'edit',:id=>r.id.to_s } %> <span
id="mytext">some text</span>

what I try to do:

render :update do |page|
page.replace_html @spanid,
                "update ok"
page.visual_effect :highlight, @spanid
end

but I get the following error:
try { } catch (e) { alert('RJS error:\n\n' + e.toString()); alert(''); throw e }

thanx in advance

Pat

Patrick Aljord wrote:

hey all,
I'm trying to replace the content of a span with "update ok" text.
That is my view :

<%= link_to_remote 'update', :update => 'updatespan',
    :url => { :action => 'edit',:id=>r.id.to_s } %> <span
id="mytext">some text</span>

what I try to do:

render :update do |page|
page.replace_html @spanid,
               "update ok"
page.visual_effect :highlight, @spanid
end

but I get the following error:
try { } catch (e) { alert('RJS error:\n\n' + e.toString()); alert(''); throw e }

thanx in advance

Pat

>

Remove the :update->'updatespan' from your link_to_remote.

Matthew Margolis
blog.mattmargolis.net

I did, now I don't get the error but I don't get nothing either

Patrick Aljord wrote:

> >
Remove the :update->'updatespan' from your link_to_remote.

I did, now I don't get the error but I don't get nothing either

>

To debug this more I would need to see the parts of your view code that deal with the element with @spanid's value as its name and the controller code that you are using to set things up for that view. Alternatively you could check out the FireBug extension for Firefox which lets you see the post and the reply to your server for the remote call. If you can see the request and response to the calls you make it is much easier to debug them.

Matthew Margolis
blog.mattmargolis.net

You can do this two ways.

If you leave in the :update then the id listed must match the id in the span you want updated:

:update => 'mytext'

Then your method should emit pure HTML which will update the item with the id in :update.

An alternative would be to remove the :update and add ":complete => evaluate_remote_response":

<%= link_to_remote 'update',
                                 :url => { :action => 'edit',:id=>r.id.to_s },
                                 :complete => evaluate_remote_response

Then use your current method (assuming @spanid contains "mytext") which will emit Javascript which will be evaluated by the "evaluate_remote_response". That Javascript will replace the current contents of the "mytext" span with "update ok".

David

Patrick Aljord wrote: