jquery-ujs
jquery-ujs copied to clipboard
Use jQuery.preventDefault instead of jQuery.stopImmediatePropagation.
I ran across a bug with using the library on an iPad. With stopImmediatePropagation, even if an alert is canceled, the action is still completed. Using preventDefault corrects the problem.
All tests pass.
@lukeseelenbinder actually we need both stopImmediatePropagation and preventDefault.
preventDefault will let the event propagate.
Test case is missing it but a good test case for this scenario will check for both cases: clicking the link does not take user away. and clicking the link does not propagate.
Should I make those changes (use both methods), produce a test case, and resubmit the pull request?
@lukeseelenbinder yes.
@lukeseelenbinder no need to resubmit a pull request. If you make the changes and add a test case, you can force push to your branch and it will update this pull request.
I can't seem to pin down where (and I'm still figuring out how) I should write the tests. It seems that .stopEverything() is not getting called at all for a['data-confirm'] elements.
.stopEverything() gets called for a['data-confirm'] elements on line 302.
The test should go in the test/data-confirm.js file.