Open bjarnef opened 8 years ago
Angular's built-in subset of jQuery, called "jQuery lite" does not has closest()
and find()
is limited to look-up by tag name:
https://docs.angularjs.org/api/ng/function/angular.element
So since it rely on use of jQuery it should be fine to use closest()
.
Alternate use addBack()
which allow to include itself: http://stackoverflow.com/a/17538213
var $pointer = $(this).find($attr.pointerNode).addBack($attr.pointerNode);
or
var $pointer = $(this).closest($attr.pointerNode);
In my example for https://github.com/shekhardesigner/Context-Menu-Angular-Directive/issues/2 I have added
pointer-node
on same element ascontext-menu
However
find()
is only looking for descendants https://api.jquery.com/find/ therefore it returns undefined.By using
closest()
it get the first element that matches the selector by testing the element itself and traversing up through its ancestors.When I in L157 change to
.closest()
instead if.find()
it works in my case. https://github.com/shekhardesigner/Context-Menu-Angular-Directive/blob/master/app/scripts/context-menu.js#L157