# Updating a new id created from Ajax call in the same .js.rjs

**URL:** <https://www.ruby-forum.com/t/updating-a-new-id-created-from-ajax-call-in-the-same-js-rjs/164385>\
**Category:** Rails\
**Created:** [March 31, 2009, 6:57pm UTC](https://www.ruby-forum.com/t/updating-a-new-id-created-from-ajax-call-in-the-same-js-rjs/164385 "2009-03-31T18:57:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![raimon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@raimon](https://www.ruby-forum.com/u/raimon)\
**Post date:** [March 31, 2009, 6:57pm UTC](https://www.ruby-forum.com/t/updating-a-new-id-created-from-ajax-call-in-the-same-js-rjs/164385/1 "2009-03-31T18:57:34Z")

</div>

Hello,

I’m playing a little with ajax and some visual effects.

What I’m doing is creating and modifying rows, open a new window with  
ajax, do the stuff, and update the main div page with the new row. The  
action can be add a new row, modify a present row, or delete a row.

If the row has been modified, I can issue a page \<\<  
visual\_effect(:highlight, @invoices\_line.id.to\_s, :duration =\> 3) and  
see the new row updated.

The problem, is that when I add a new row, the new id doesn’t exist in  
the main page, but it really exists in the new updated div, but it seems  
that the javascript can’t find it.

Without reloading, modifying the just created row, the visual effect  
works.

Maybe isn’t working because I’m calling the visaul effect after the  
update and the browser/javascript doesn’t know (yet) the newly ID ?

For testing purposes I added an alert with the new id to see if it  
really exists, and before the alert I update the div, and I can see that  
the new row with the new id really exists (has been updated…)

The error that I’m getting is RJS Error [obejct Object]

any ideas ?

thanks …

r.
