render :partial from .js.erb doesn't render on second pass ...


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

[SOLVED] should use .htl() and not .replaceWith()