I have an angular -strap datepicker that I want to show only on right click.
I want to do this using the focus () method by default, since it is convenient for closing things when they blur. To use the focus method for any element, such as a DIV, I added tabindex.
The problem is that I cannot turn off focus only on the left click. It is either completely disabled or works for both.
I have already forbidden the context menu to show on the right click.
directives.directive('ngRightClick', ["$parse", function($parse) {
return function(scope, element, attrs) {
var fn = $parse(attrs.ngRightClick);
element.bind('contextmenu', function(event) {
scope.$apply(function() {
event.preventDefault();
fn(scope, {$event:event});
});
});
};
}])
For a left click, I tried to prevent Default (), but this does not work. Then I tried to blur it on a click that works, but the focal event is still triggered in advance, for a split second.
directives.directive('ngLeftNofocus', ["$parse", function($parse) {
return function(scope, element, attrs) {
var fn = $parse(attrs.ngLeftNofocus);
element.bind('click', function(event) {
scope.$apply(function() {
event.preventDefault();
element[0].blur();
});
});
};
}])
Plnkr: http://plnkr.co/edit/T2YBYwfqSLKxCUL0ITgk?p=preview
, jQuery , , .
, - datepicker ( , ), .