I have jQuery Mobile on iPad Safari, and for some reason, touch-swipe events fire twice.
People have reported the same issue in the past year as they did this week, but I canβt find an explanation of how to fix a double event without changing jQuery Mobile, and I donβt want to. JQuery forum topic
Binding snap elements for a napkin handler has the same incorrect double-event result when a warning is raised twice for each scroll.
How should jQuery Mobile touch events be connected to avoid double bubbling?
// Test 1: Binding directly to document with delegate() $(document).delegate(document, 'swipeleft swiperight', function (event) { alert('You just ' + event.type + 'ed!'); }); // Test 2: Binding to document with on() handler recommended as of 1.7 with and without preventDefault $(document).on('swipeleft',function(event, data){ event.preventDefault(); alert('You just ' + event.type + 'ed!'); }); // Test 3: Binding to body with on() with and without event.stopPropagation $('body').on('swipeleft',function(event, data){ event.stopPropagation(); alert('You just ' + event.type + 'ed!'); }); // Test 4: Binding to div by class $('.container').on('swipeleft',function(event, data){ event.stopPropagation(); alert('You just ' + event.type + 'ed!'); });
Dylan valade
source share