Forum: Ruby on Rails rjs and partials

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ff82af3238a57fbd1212832ec1a19f28?d=identicon&s=25 Dylan Stamat (Guest)
on 2006-03-07 19:05
(Received via mailing list)
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:

     page.insert_html :top, 'items',  :partial => 'item'
     page.visual_effect :highlight, @item_id, :duration => 3


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 ?
5d15c6821f3c3054c04b85471824ba7c?d=identicon&s=25 Kevin Olbrich (Guest)
on 2006-03-07 21:04
(Received via mailing list)
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
1843ba3c4ff9cc702bc3474223a0acc6?d=identicon&s=25 Tony Jin (tony)
on 2006-03-07 22:52
Dylan Stamat wrote:

> 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

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
Ff82af3238a57fbd1212832ec1a19f28?d=identicon&s=25 Dylan Stamat (Guest)
on 2006-03-07 23:47
(Received via mailing list)
Thanks guys.  Tony, you were right on #1... the DOM was,
ever-so-slightly,
broken ;)
4005a47a8f2ceee49670b920593c1d52?d=identicon&s=25 Ben Munat (Guest)
on 2006-03-08 04:48
(Received via mailing list)
Kevin Olbrich 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
Ff82af3238a57fbd1212832ec1a19f28?d=identicon&s=25 Dylan Stamat (Guest)
on 2006-03-08 06:34
(Received via mailing list)
This is a gem.  Thank you very much Ben !
This topic is locked and can not be replied to.