Templarian / ui.bootstrap.contextMenu

AngularJS Bootstrap UI Context Menu
MIT License
259 stars 127 forks source link

Open context menu programmatically #104

Closed qti3e closed 7 years ago

qti3e commented 7 years ago

Hello, everyone. I'm just wondering is there any existing API for opening context menu programmatically? Something like:

menuOptions = [
    [function ($itemScope, $event, modelValue) {
        return $itemScope.item.name;
    }, function ($itemScope, $event, modelValue) {
        // Action
    }, function($itemScope, $event, modelValue) {
        // Enable or Disable
        return true; // enabled = true, disabled = false
    }]
];
$scope.open = function(){
    // code to open context menu
}

Thanks for your helping :-)

qti3e commented 7 years ago

Can anyone help me? please

josetaira commented 7 years ago

You can do so by triggering the event that the context menu is attached to. Something like:

var event = jQuery.Event("contextmenu", {});
$element.trigger(event);