I''m having trouble getting yellow fade, or any effect, to work when updating a list using form_remote_tag. I''ve followed the example in the Agile Ror book pretty closely, and I can get the ajax method to call and it actually updates the screen with the new value, but I cannot, for the life of me, get the effect to work. Heres what I''m trying, cribbed from pg 407 of the book. <% content_for("page_scripts") do %> function item_added(){ var new_address = $(''show_addresses'').firstChild; new Effect.Highlight(new_address); } <% end %> <ul id="show_addresses"> <%= render(:partial =>''show_addresses'', :collection =>@addresses)%> </ul> <div id="get_address"> <%= form_remote_tag(:url => {:action=>"add_address"}, :update =>"show_addresses", :position =>"top", :complete =>"item_added()")%> . . the show_address partial is pretty simple. <li <p> <%=h(show_addresses.name) %> </p> </li> Almost to mock my effort and pain, I made the submit button display the effect: <input type="submit" value="add address" onclick="new Effect.Highlight(this)"/> And that worked just fine. I''ve wasted 2.5 hours on this and I''m stumped. Has anyone else had trouble getting an effect to trigger after an Ajax update? TIA -Alex
Hi Alex, I have found that when an effect won''t work it is due to a javascript error of some sort. If you are using Firefox/Mozilla/Netscape, you can type "javascript:" (no quotes) into your address bar and it should point you in the right direction. Good Luck, Tom On 10/18/05, Alex Reuter <reuter-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> I''m having trouble getting yellow fade, or any effect, to work when updating a > list using form_remote_tag. > > I''ve followed the example in the Agile Ror book pretty closely, and I can get > the ajax method to call and it actually updates the screen with the new value, > but I cannot, for the life of me, get the effect to work. > > Heres what I''m trying, cribbed from pg 407 of the book. > > <% content_for("page_scripts") do %> > function item_added(){ > var new_address = $(''show_addresses'').firstChild; > new Effect.Highlight(new_address); > } > <% end %> > <ul id="show_addresses"> > <%= render(:partial =>''show_addresses'', :collection =>@addresses)%> > </ul> > <div id="get_address"> > <%= form_remote_tag(:url => {:action=>"add_address"}, > :update =>"show_addresses", > :position =>"top", > :complete =>"item_added()")%> > . > . > the show_address partial is pretty simple. > <li > <p> > <%=h(show_addresses.name) %> > </p> > </li> > > Almost to mock my effort and pain, I made the submit button display the effect: > <input type="submit" value="add address" onclick="new Effect.Highlight(this)"/> > And that worked just fine. > > I''ve wasted 2.5 hours on this and I''m stumped. Has anyone else had trouble > getting an effect to trigger after an Ajax update? > > TIA > -Alex > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Tom Davies <atomgiant@...> writes:> I have found that when an effect won''t work it is due to a javascript > error of some sort. If you are using Firefox/Mozilla/Netscape, you > can type "javascript:" (no quotes) into your address bar and it should > point you in the right direction.Thanks for the tip Tom, but there doesn''t appear to be any javascript errors in the console. Oh well. I''ll drop this for now, probably shouldn''t have spent so much time getting a yellow flash to work for a version 0.1 anyway.
Yeah, the AJAX stuff can consume some time debugging it if doesn''t work quite right. Once you get back to it, I would say try your item_added without AJAX, as in: <input type="submit" value="add address" onclick="item_added()"/> If that works, then try it with AJAX and check your development log for errors. I sometimes will modify the controller to just display the response to the browser instead of as an AJAX call so I can verify the output is what I expected. Good luck, Tom On 10/18/05, Alex Reuter <reuter-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> Tom Davies <atomgiant@...> writes: > > I have found that when an effect won''t work it is due to a javascript > > error of some sort. If you are using Firefox/Mozilla/Netscape, you > > can type "javascript:" (no quotes) into your address bar and it should > > point you in the right direction. > > Thanks for the tip Tom, but there doesn''t appear to be any javascript errors > in the console. Oh well. I''ll drop this for now, probably shouldn''t have > spent so much time getting a yellow flash to work for a version 0.1 anyway. > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >