diff options
| author | Braden Shepherdson | 2013-07-24 16:34:30 -0700 | 
|---|---|---|
| committer | Igor Minar | 2013-07-24 19:02:06 -0700 | 
| commit | fb7d891dacdcb9f799061d5fbb96cdd2dd912196 (patch) | |
| tree | 4b07fa9a2e71e1193bb03b0c16accb0cf13e9f85 /src | |
| parent | d87fa0042375b025b98c40bff05e5f42c00af114 (diff) | |
| download | angular.js-fb7d891dacdcb9f799061d5fbb96cdd2dd912196.tar.bz2 | |
fix(ngMobile): emit click event for touchy clicks
Previously, no handlers for the click event would be called for the
fast, touch-based ngMobile clicks, only for desktop browser clicks. Now
the event will fire properly for all clicks.
Closes #3219
Closes #3218
Closes #3137
Diffstat (limited to 'src')
| -rw-r--r-- | src/ngMobile/directive/ngClick.js | 13 | 
1 files changed, 7 insertions, 6 deletions
| diff --git a/src/ngMobile/directive/ngClick.js b/src/ngMobile/directive/ngClick.js index 358a1af9..51e201c2 100644 --- a/src/ngMobile/directive/ngClick.js +++ b/src/ngMobile/directive/ngClick.js @@ -233,9 +233,7 @@ ngMobile.directive('ngClick', ['$parse', '$timeout', '$rootElement',          }          if (!angular.isDefined(attr.disabled) || attr.disabled === false) { -          scope.$apply(function() { -            clickHandler(scope, {$event: event}); -          }); +          element.triggerHandler('click', event);          }        } @@ -246,9 +244,12 @@ ngMobile.directive('ngClick', ['$parse', '$timeout', '$rootElement',      // something else nearby.      element.onclick = function(event) { }; -    // Fallback click handler. -    // Busted clicks don't get this far, and adding this handler allows ng-tap to be used on -    // desktop as well, to allow more portable sites. +    // Actual click handler. +    // There are three different kinds of clicks, only two of which reach this point. +    // - On desktop browsers without touch events, their clicks will always come here. +    // - 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) {        scope.$apply(function() {          clickHandler(scope, {$event: event}); | 
