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
Allow PJAX to be used on form submission #80
Conversation
I don't think this is a good direction for pjax. PJAXing simple Form submissions aren't always going to degrade and are going to cause problems with |
Sure thing Josh, Up to you. I guess it works pretty well for us, but we only use it for very simple CRUD forms with well defined behaviours. Certainly I can see where it might be a problem with Any thoughts on a what a good way to integrate our AJAX forms into the PJAX fold? Right now (with the above changes) we have a nice system where a |
Pjax doesn't do anything special with |
Alright, cheers. I'll close this then. |
Alright, somewhat interested in aspects of this.
$(document).on "submit", "#form", ->
$.pjax
type: this.method
url: this.action
data: $(this).serializeArray()
container: "#container"
false |
|
I think we can handle those special case errors better by adding more custom Yeah, we need server side hacks. Thinking of proposing a I'm probably going to do something similar like |
Response headers -- yes, this is easily achieved via an
$('form[data-pjax]').pjax(); Re custom events: This is more troublesome..
|
Working on POST fallback in #95 |
Let me know if you need anything.. |
@tmeasday How do you think we should handle back and forth? So you submit a form, then click back, then forward. Normally browsers warn you about double submissions. Maybe we need to do something similar. Also, theres a storage limit in |
Yeah, that's a tricky one. Of course you could hack something together where your Or you could just not allow re-submissions, it's often broken for sites anyways, so I don't know if it'd be a big loss. In case you are interested: we sort of get away with it by just relying on standard REST routes + always doing
If you hit back now, you'll see But it's exceedingly brittle, and won't work for anything non-standard, maybe not even for simple |
Yeah, I'm probably over thinking this then. I like that fallback. Should probably at least fix serializing post data to a query string. Heh, that would not be a good idea for forms. https://github.com/defunkt/jquery-pjax/blob/master/jquery.pjax.js#L220-222 |
Ha, yeah right, I didn't even realise that pjax was saving it, and making a So the fallback is on |
This is how I make PJAX display content of 422 error pages:
|
Not as complicated a commit as it looks. Does a couple things
Also there's a very minor change, which is to wrap the result from the server in a
<div>
before trying to extract the fragment, in case all the server returns is the fragment.Let me know if there's anything I can do to simplify it.