# Rjs and partials

**URL:** <https://www.ruby-forum.com/t/rjs-and-partials/54523>\
**Category:** Rails\
**Created:** [March 7, 2006, 7:05pm UTC](https://www.ruby-forum.com/t/rjs-and-partials/54523 "2006-03-07T19:05:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dylan\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/34f0e0/32.png) [@Dylan\_S](https://www.ruby-forum.com/u/Dylan_S)\
**Post date:** [March 7, 2006, 7:05pm UTC](https://www.ruby-forum.com/t/rjs-and-partials/54523/1 "2006-03-07T19:05:49Z")

</div>

I’m trying to update a list, and having a hard time applying visual  
effects  
to the latest element created. Here is what I’m doing.

===========================================

1. Creating an “item” via an action, then rendering the RJS template

2. RJS template looks like this:

3. Once all this is done, I check the source of the page, and an item  
with  
the @item\_id doesn’t exist in the HTML yet… as it’s just being ajaxed  
from  
the  
partial. If I refresh the page, it’s obviously there.  
===========================================

So, my question is… is there a clean way to create an effect on a  
newly  
created element in a list ?

---

<div class="post-metadata">

**Author:** ![Dylan\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/34f0e0/32.png) [@Dylan\_S](https://www.ruby-forum.com/u/Dylan_S)\
**Post date:** [March 7, 2006, 9:04pm UTC](https://www.ruby-forum.com/t/rjs-and-partials/54523/2 "2006-03-07T21:04:52Z")

</div>

Most browsers will give you the source of the original request back, not  
the source of the current page after ajax magic has happend.

I think that one of the firefox developer plugins can give you the  
current source, so you might want to give that a shot.

\_Kevin

---

<div class="post-metadata">

**Author:** ![Dylan\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/34f0e0/32.png) [@Dylan\_S](https://www.ruby-forum.com/u/Dylan_S)\
**Post date:** [March 7, 2006, 10:52pm UTC](https://www.ruby-forum.com/t/rjs-and-partials/54523/3 "2006-03-07T22:52:25Z")

</div>

Dylan S. wrote:

> 1. Once all this is done, I check the source of the page, and an item  
> with  
> the @item\_id doesn’t exist in the HTML yet… as it’s just being ajaxed

It won’t show via “view source”, since view source will only show the  
DOM elements  
when page is loaded, now the DOM elements are changed, but view source  
won’t  
show the change.

Your example normally should work. If it doesn’t work, it could be:

1. If the new item is now showing, your partial tempatelate might not be  
rendered  
right, or the return result from it might break your DOM structure;
2. If the new item is added, but highlight is not working, variable  
@item\_id might  
not be defined in the controller corresponding to your rjs  
template(not the  
one calling the rjs)

-Tony

---

<div class="post-metadata">

**Author:** ![Dylan\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/34f0e0/32.png) [@Dylan\_S](https://www.ruby-forum.com/u/Dylan_S)\
**Post date:** [March 8, 2006, 4:48am UTC](https://www.ruby-forum.com/t/rjs-and-partials/54523/4 "2006-03-08T04:48:14Z")

</div>

Kevin O. wrote:

> I think that one of the firefox developer plugins can give you the  
> current source, so you might want to give that a shot.

[http://jennifermadden.com/scripts/ViewRenderedSource.html](http://jennifermadden.com/scripts/ViewRenderedSource.html)

---

<div class="post-metadata">

**Author:** ![Dylan\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/34f0e0/32.png) [@Dylan\_S](https://www.ruby-forum.com/u/Dylan_S)\
**Post date:** [March 7, 2006, 11:47pm UTC](https://www.ruby-forum.com/t/rjs-and-partials/54523/5 "2006-03-07T23:47:08Z")

</div>

Thanks guys. Tony, you were right on #1… the DOM was,  
ever-so-slightly,  
broken 😉

---

<div class="post-metadata">

**Author:** ![Dylan\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/34f0e0/32.png) [@Dylan\_S](https://www.ruby-forum.com/u/Dylan_S)\
**Post date:** [March 8, 2006, 6:34am UTC](https://www.ruby-forum.com/t/rjs-and-partials/54523/6 "2006-03-08T06:34:37Z")

</div>

This is a gem. Thank you very much Ben !
