What does ion-stop-event do? I can’t seem to find the code for it.
I want to cancel event propagation between nested ng-click calls. Is there an ionic prebuilt function?
Here are my current solution:
.directive('stopEvent', function () {
return {
restrict: 'A',
link: function (scope, element, attr) {
element.bind('click', function (e) {
e.preventDefault(); // added for ionic
e.stopPropagation();
});
}
};
});
2 Likes
Hm, the directive you have here seems to work fine here, swipe open the list item and tap Cancel Event
Could you provide a more accurate example to your situation?
My directive works fine. While doing research I found ion-stop-event and was wondering if it did the same thing. Therefore, I could use it instead of my version.
jajohga:
ion-stop-event
You know that is a good question. There isn’t any documentation but from the looks of the code, I’m guessing it’s just a utility directive.
Don’t see anything stopping you from using it.
clickHandler(scope, {$event: (event)});
});
});
// Hack for iOS Safari's benefit. It goes searching for onclick handlers and is liable to click
// something else nearby.
element.onclick = function(event) { };
};
}])
.directive('ngClick', ['$ionicNgClick', function($ionicNgClick) {
return function(scope, element, attr) {
$ionicNgClick(scope, element, attr.ngClick);
};
}])
.directive('ionStopEvent', function () {
return {
restrict: 'A',
link: function (scope, element, attr) {
element.bind(attr.ionStopEvent, eventStopPropagation);
1 Like
I’ve also noticed this isn’t in the docs, and would like to see it there.
1 Like
mitch42
September 28, 2014, 3:45pm
6
Seems that this directive originated here : https://github.com/driftyco/ionic/issues/550
adding ion-stop-event="click"
does the trick.
Hope this helps !
3 Likes