How to manage the contextmenu of jsTree as per the file and folder

contextmenujstree

I have stuck to manage the contextmenu after the right click . Actually I need to display some item of contextmenu for folder and some item of contextmenu for folder.

On click of folder context menu will look like :

  • create
  • remove
  • rename
  • new

On click of file context menu will look like :

  • create
  • remove
  • rename

Is there any way to manage this menu after click . I have look into documentation and other blog , but not getting useful content .

Can you please guide me some thing so that I can implement like that .

Thanks in advance

Best Answer

Hello ,

Thanks for take a look, but I got the way to make it Please take a look on below :

$('#detail_dir_container').jstree({
      "json_data" : {
        "ajax" : { 
          "url" : ''
        }
      },
      "contextmenu" : {
              "items": function(node){
                    if(node.attr('type') == 'file' )
                    {
                      return {
                        create : true,
                        rename : true,
                        remove : true
                     }
                  }
                  else
                  {
                    return {
                      create : true,
                      rename : true,
                      remove : true,
                      new    : true,
                    }
                  }
        }
    });



Thanks
Related Topic