Templarian / ui.bootstrap.contextMenu

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

Close context menu in code #106

Closed gwinnem closed 7 years ago

gwinnem commented 7 years ago

Is it possible to close the context menu in javascript ?

josetaira commented 7 years ago

Yup, you just need to trigger the jQuery event "mousedown" on $(document.body)

If you look at the code, you'll see there's a listener to this event. This will trigger all other mousedown events though. There's no direct way to close the contextmenu that's exposed currently. If you really need this, let me know.

gwinnem commented 7 years ago

I am triggering the below code: But context menu is still open until i click the modal, but i need it to close automatically $(document.body).trigger("mousedown"); var kendoTree = this.tree; var dataItem = this.tree.dataItem(this.tree.select()); $scope.dataItem = kendoTree.dataItem(kendoTree.select()); var modalDefaults = { controller: "FolderAddController" }; var modalOptions = { kendoTree: kendoTree, dataItem: dataItem, headerText: $scope.translation.AddFolder, actionButtonText: $scope.translation.Save, contentUrl: "Scripts/app/FileManager/Templates/folder-add-form.html" }; $scope.openDialog(modalDefaults, modalOptions);

josetaira commented 7 years ago

What version of the context-menu are you using? If it's an old one this might work instead:

$(".angular-bootstrap-contextmenu").mousedown()

or

$(".angular-bootstrap-contextmenu").trigger("mousedown")

It's because the binding for the close was different before.

gwinnem commented 7 years ago

I am using the code from github but i still have the same issue.

On 9 May 2017 at 12:38, Jose Taira notifications@github.com wrote:

What version of the context-menu are you using? If it's an old one this might work instead:

$(".angular-bootstrap-contextmenu").mousedown()

It's because the binding for the close was different before.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Templarian/ui.bootstrap.contextMenu/issues/106#issuecomment-300126417, or mute the thread https://github.com/notifications/unsubscribe-auth/AGIR8Pdlo79pq9xwAZqkt_64i54COrGSks5r4EIagaJpZM4NU_wY .

gwinnem commented 7 years ago

Found a fix by adding $("ul").remove(".dropdown-menu"); to the code in the menu items to enforce that the menu is removed before i open my modal box.