prototype-ujs
prototype-ujs copied to clipboard
"data-confirm" with form inconsistent
prototype-ujs expects that the data-confirm
be on the form element rather than the submit button. button_to
helper in rails adds it to the submit input. As well, I believe the jquery-ujs driver expects the attribute on the submit input.
I don't think my fix is an end all as it's pretty flawed (if you have existing forms with data-confirm) but may work as a quick fix for folks running into this. Anyway, a heads up on the issue.
Bit of a shame to find this pull request from months ago. I encountered exactly the same issue - basically, prototype-ujs at the time of writing is not entirely compatible with the documented Rails v3.1.1 API and legacy applications may fail to work properly as a result (mine certainly did). It's very difficult to find with automated tests too, since it's a user interface level JavaScript interaction fault.
My solution was to duplicate the allowAction() check from the "submit" handler into the "click" handler - something like:
if (button && !allowAction(button)) {
event.stop();
return false;
}
...before the "event.findElement" call.
Either way this really needs fixing - people are submitting patches; why are these not being included? I'd love to see this merged in ASAP. I'm not interested in the latest fad or flame war about jQuery vs Prototype; I'm interested in using Prototype on Rails 3 so I can upgrade a legacy application without having to rewrite every line of JS code to deal with a different library. It's not rapid application development if I have to keep rewriting the same application over and over :-)