Skip to content

update specific contextMenu #676

Open

Description

@Kvasha123

I'm having the Problem, that i can't figure out how i specify a specific contextMenu that i want to update (change items to display as disabled).

You have the following functionality that i tried:

$('.context-menu-one').contextMenu('update'); // update single menu
$.contextMenu('update') // update all open menus

the second function works, but updates all menus (as said), but what selector should be used for the first function instead of $('.context-menu-one').

I tried to give the menu an class and use these class as selector, but no success.

I hope someone can help here

Activity

  1. Kvasha123 commented on Jan 14, 2019

    @Kvasha123
    Author

    I would be okay with
    $.contextMenu('update');
    but this opens the closed menus as well

  2. bbrala commented on Jan 16, 2019

    @bbrala
    Member

    The selector should be the same as the selector that was used to initialize the contextmenu. So the selector on which the menu is bound.

  3. Kvasha123 commented on Jan 17, 2019

    @Kvasha123
    Author
    $.contextMenu({
    		selector: 	'#ctxSelector a',
    		build: function($triggerElement, e){
    	        return {
    	        	callback: function(){},
    	        	items: {
    	    	    	'item1': {
    	    	    		name: 'Item 1',
    	    	    		icon: 'fas fa-route'
    	    	    	},
    	    	    	'item2': {
    	    	    		name: 'Item 2',
    	    	    		icon: 'fas fa-draw-polygon'
    	    	    	}
    	            }
    	        }
    		}
    	});
    

    So in my case, the selector would be '#ctxSelector a' ?

  4. bbrala commented on Jan 17, 2019

    @bbrala
    Member

    Yes it should be.

  5. Kvasha123 commented on Jan 21, 2019

    @Kvasha123
    Author

    It's not working. And I have no idea why. I have JSF in my Project, could that be the problem?

  6. whilelfo commented on Sep 10, 2020

    @whilelfo

    Old topic but, try this:
    $.contextMenu('update', { context: $.contextMenu.menus[".contextMenu2"] }); // update single menu

    if you're talking about updating only the 2nd created menu,

  7. whilelfo commented on Sep 11, 2020

    @whilelfo

    Actually, It seams to have a bug at the single menu update:
    I've changed the line 1656 to: op.update(o.context);
    And so, I've called the update like this:
    $.contextMenu('update', { context: [$.contextMenu.menus[".contextMenu2"]] });
    The array "context" is required to pass some verification's.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions