From 9fd92cc3c93a6378e8887fd46fd4ad182a375544 Mon Sep 17 00:00:00 2001 From: Steven Sojka Date: Wed, 4 Sep 2013 11:20:33 -0500 Subject: fix(ngTouch): ngClick does not pass touchend event when jQuery is loaded The trigger handler event in jqLite takes an event object as a second parameter, but jQuery requires an array of parameters. This is causing the touchend event to not come thtough in the click handler when jQuery is loaded. --- src/jqLite.js | 9 ++++++--- src/ngTouch/directive/ngClick.js | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/jqLite.js b/src/jqLite.js index d3110788..8075d874 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -803,13 +803,16 @@ forEach({ triggerHandler: function(element, eventName, eventData) { var eventFns = (JQLiteExpandoStore(element, 'events') || {})[eventName]; - eventData = eventData || { + + eventData = eventData || []; + + var event = [{ preventDefault: noop, stopPropagation: noop - }; + }]; forEach(eventFns, function(fn) { - fn.call(element, eventData); + fn.apply(element, event.concat(eventData)); }); } }, function(fn, name){ diff --git a/src/ngTouch/directive/ngClick.js b/src/ngTouch/directive/ngClick.js index d6e404ca..7dcc4041 100644 --- a/src/ngTouch/directive/ngClick.js +++ b/src/ngTouch/directive/ngClick.js @@ -238,7 +238,7 @@ ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement', } if (!angular.isDefined(attr.disabled) || attr.disabled === false) { - element.triggerHandler('click', event); + element.triggerHandler('click', [event]); } } @@ -255,9 +255,9 @@ ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement', // - On mobile browsers, the simulated "fast" click will call this. // - But the browser's follow-up slow click will be "busted" before it reaches this handler. // Therefore it's safe to use this directive on both mobile and desktop. - element.on('click', function(event) { + element.on('click', function(event, touchend) { scope.$apply(function() { - clickHandler(scope, {$event: event}); + clickHandler(scope, {$event: (touchend || event)}); }); }); -- cgit v1.2.3