Pergunta

I am using the jQuery dynatree along with the context menu found here. The issue I'm having is that I can't get the enable/disable of the context menu or individual items in the menu to work. The plugin says I should be able to do this:

$("#contextMenu").enableContextMenu();

but that doesn't work for me. Here's the menu:

 <!-- Definition of context menu -->
 <div id="contextMenu">
     <ul id="myMenu" class="contextMenu">
       <li class="resubmit"><a href="#resubmit">Resend</a></li>
     </ul>
 </div>

The menu shows and works fine if I don't put any enable/disable, but there are cases where the menu item is not available so I need to be able to control its state. If I put in the enable/disable, the manu doesn't show at all.

Can anyone share how they got this to work?

UPDATE: I can only get the menu to show if I remove the DIV above. Then it will show, but enable/disable using "myMenu" does nothing...

Foi útil?

Solução 2

I couldn't disable the menu itself, so I had to handle it after the item is selected:

switch( action ) 
{
    case "resubmit":
        //-- show verify dialog
      var selectedNode = $("#tree").dynatree("getActiveNode");
      if(selectedNode == null) 
           break;
      var parentTitle = selectedNode.parent.data.title;
      if( parentTitle == "Error" || parentTitle == "To Lab" || parentTitle == "From Lab" )
            $('#dialog-confirm').dialog('open');
             break;
    default:
             alert("Invalid action '" + action + "' to node " + node);
}

I just check that the proper type node is selected to be able to take the action (look at parent, which is the containing folder).

Outras dicas

Came across the same issue, you can actually disable the context menu trigger like:

$(".dynatree-title").contextMenu(false)

And re-enable it with True. dynatree-title being the element the trigger is bound to.

Hope this helps anyone else who stumbles across this.

Context menu documentation

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top