It doesn't say you that you HAVE to bind all the ajax events. It explicitly
says that you "probably" want to do that if you "probably" want to do
something other than just submitting the form.

El dom., 16 feb. 2020 a las 17:53, Momeas Interactive (<t...@datatravels.com>)
escribió:

> it says here in the docs that for turobolinks that you now have to BIND
> ALL YOUR AJAX EVENTS  (!?!?) if you want your forms to submit correctly.
>
>
> https://guides.rubyonrails.org/working_with_javascript_in_rails.html#remote-elements
>
>
> "You probably don't want to just sit there with a filled out <form>,
> though. You probably want to do something upon a successful submission. To
> do that, bind to the ajax:success event. On failure, use ajax:error. Check
> it out:"
>
> $(document).ready ->
>   $("#new_article").on("ajax:success", (event) ->
>     [data, status, xhr] = event.detail
>     $("#new_article").append xhr.responseText
>   ).on "ajax:error", (event) ->
>     $("#new_article").append "<p>ERROR</p>"
>
>
> basically… sitting there with a filled out form is exactly what happens if
> you just do a generic form_with and post it now in Rails 6 … literally, the
> user just sits there and nothing happens.
>
> are you really supposed to bind all your turbolinks forms throughout your
> website like this? This seems totally nuts to me, and, kind of, not at all
> 'unobtrusive' … (I thought the whole point of 'unobtrusive' was to not have
> to write a lot of helper/glue/boiler plate code.)
>
> it seems totally crazy to me that out-of-the-box Rails 6 installations
> can't do the most basic web function of submitting a form without the
> developer having to know about binding events of the Ajax calls. In the old
> days didn't this used to 'just work' out of the box?
>
> anyone else have any thoughts on this and think Rails is moving in the
> wrong direction here? The main attraction of Rais is how easy it is to make
> so much functionality with little config and effort, and this area seems
> too basic to me to require this top-heavy approach that requires binding up
> Ajax events.
>
> I think Rails 7 should move away from having turbolinks turned on by
> default — it's a good technology if you want to opt-in to it, but it's got
> so much configuration that it often just gets in the way for new Rails
> apps. It would be very easy to simply leave off Turbolinks in default Rails
> apps and then simply provide instructions for opting-in to it. (Like,
> active record session store and other things that used to be default and
> then were extracted out into separate opt-in gems.)
>
>
> Thoughts?
>
> Jason
>
>
>
>
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/511637f0-dec3-4bd1-9648-a823c140669b%40googlegroups.com
> <https://groups.google.com/d/msgid/rubyonrails-talk/511637f0-dec3-4bd1-9648-a823c140669b%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcA%2BWbyWwg%2BpWgerkaLA5QmxofgfXUN-Nv1krTyYuoWjjg%40mail.gmail.com.

Reply via email to