Erwin
2012-Jan-07 15:17 UTC
render :partial from .js.erb doesn''t render on second pass ...
VIEWS contacts/new.html.haml ... .contact_details = render :partial => "contacts/details" contacts/_details.html.haml .. %b= regions_in_area(@area) # from contacts_helper.rb sending back a string according to @area upon a drop down change , an Ajax request is send to contacts#change_area action with a new area found : def change_area @area = Area.find(params[:id]) render "contacts/change_area.js" end and the change_area.js is very simple , replacing the .contact_details $(''.contact_details'').replaceWith( ''<%escape_javascript(render :partial => "contacts/details") %>''); this runs very well on the first drop down change, but on the second change, even if the @area is changed and also the string from the helper... the new string is NOT displayed ... what''s wrong in my code ? thanks for your feedback -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Erwin
2012-Jan-07 17:26 UTC
Re: render :partial from .js.erb doesn''t render on second pass ...
[SOLVED] should use .htl() and not .replaceWith() On Jan 7, 4:17 pm, Erwin <yves_duf...-ee4meeAH724@public.gmane.org> wrote:> VIEWS > > contacts/new.html.haml > ... > .contact_details > = render :partial => "contacts/details" > > contacts/_details.html.haml > .. > %b= regions_in_area(@area) # from contacts_helper.rb sending back > a string according to @area > > upon a drop down change , an Ajax request is send to > contacts#change_area action with a new area found : > def change_area > @area = Area.find(params[:id]) > render "contacts/change_area.js" > end > > and the change_area.js is very simple , replacing the .contact_details > $(''.contact_details'').replaceWith( ''<%> escape_javascript(render :partial => "contacts/details") %>''); > > this runs very well on the first drop down change, but on the second > change, even if the @area is changed and also the string from the > helper... the new string is NOT displayed ... > > what''s wrong in my code ? > > thanks for your feedback-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.