In my Rails 5 / Turbolinks 5 application i would like to put the html resulting from a form submission into a div.
The form is a
= form_for(user) do |f|
standard rails form.
After a successful submission a redirect is send to the browser
respond_to do |format|
if @user.save
format.html { redirect_to @user, notice: 'User was created.' }
when i submit the form via ajax:
$(".dialog").on("submit", "form", function(e){
e.preventDefault();
$.ajax({
url: $(this).attr("action"),
method: "POST",
data: $(this).serialize()
}).done(function(data) {
$(".dialog .canvas").html(data);
});
});
the from gets submitted and the server's redirect_to statement redirects the browser the the new user's page.
The redirect causes turbolinks to replace the body with the content of the page the browser was redirected to. instead i want to replace a specific div $(".dialog .canvas").html(data). how can i prevent this behaviour of turbolinks.