Ruby on Rails
Wednesday, June 17, 2015
With Convention over configuration, you can usually trust the defaults to get you there. In this case, not so much. I've been banging my head on the wall for a few hours now, in between trying things and researching.
For the usual cases, how do I set up an AJAX form. Is it using JS or JSON format?
**Case 1: `form_for remote: true` default, `format.js`**
UJS sends a request as JS.
Exception: Missing template for update.js.
`form_for remote: true, format: :json`
No difference in HTML output, though `form_for` doc examples says you can do that.
**Case 2: `form_for remote: true, html: {"data-type" => :json}` not the default**
Responder will answer 204, but why is this not default in either `form_for` or UJS?
What is the expected use case and can it be documented? I suspect it's the latter, but I expected there to be good defaults in place.
-- For the usual cases, how do I set up an AJAX form. Is it using JS or JSON format?
**Case 1: `form_for remote: true` default, `format.js`**
UJS sends a request as JS.
Exception: Missing template for update.js.
`form_for remote: true, format: :json`
No difference in HTML output, though `form_for` doc examples says you can do that.
**Case 2: `form_for remote: true, html: {"data-type" => :json}` not the default**
Responder will answer 204, but why is this not default in either `form_for` or UJS?
What is the expected use case and can it be documented? I suspect it's the latter, but I expected there to be good defaults in place.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ea8116ca-1bd3-477e-9170-81c521ad37a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment