New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Body not being replaced after form submission #119

Closed
bryanvero opened this Issue Jun 16, 2016 · 2 comments

Comments

Projects
None yet
3 participants
@bryanvero
Copy link

bryanvero commented Jun 16, 2016

I have added :remote => true to my devise sign_up form, and I can see that now the form is being submitted via XHR, and that the response comes back with the proper HTML that should be shown (showing validation failures), but Turbolinks is not replacing the HTML content.

My application.js is simple:

//= require jquery
//= require jquery_ujs
//= require turbolinks

Why isn't the body being replaced?

@packagethief

This comment has been minimized.

Copy link
Member

packagethief commented Jun 20, 2016

Hi @bryanvero. Turbolinks doesn't handle XHR form submission. If you want to update the page in response to an XHR, you can return a JavaScript string and evaluate it. Since you're using Rails with jQuery, the JavaScript response will be evaluated automatically.

This technique is known generally as "Server-generated JavaScript Responses" or SJR for short. You can read the linked article for an explanation and some examples.

@codyrobbins

This comment has been minimized.

Copy link

codyrobbins commented Jun 2, 2017

See #85 for a more complete discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment