jquery-ujs icon indicating copy to clipboard operation
jquery-ujs copied to clipboard

Use jQuery.preventDefault instead of jQuery.stopImmediatePropagation.

Open lseelenbinder opened this issue 13 years ago • 6 comments
trafficstars

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.

lseelenbinder avatar Mar 29 '12 14:03 lseelenbinder

@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.

neerajsingh0101 avatar Mar 29 '12 15:03 neerajsingh0101

Should I make those changes (use both methods), produce a test case, and resubmit the pull request?

lseelenbinder avatar Apr 01 '12 02:04 lseelenbinder

@lukeseelenbinder yes.

neerajsingh0101 avatar Apr 01 '12 11:04 neerajsingh0101

@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.

JangoSteve avatar Apr 02 '12 06:04 JangoSteve

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.

lseelenbinder avatar Apr 03 '12 13:04 lseelenbinder

.stopEverything() gets called for a['data-confirm'] elements on line 302.

The test should go in the test/data-confirm.js file.

JangoSteve avatar Apr 03 '12 16:04 JangoSteve