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 ?
on 2006-03-07 20:05
on 2006-03-07 22:04
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
on 2006-03-07 23:52
Dylan S. 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
on 2006-03-08 00:47
Thanks guys. Tony, you were right on #1... the DOM was, ever-so-slightly, broken ;)
on 2006-03-08 05:48
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
on 2006-03-08 07:34
This is a gem. Thank you very much Ben !