Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 874
Vik Avatar asked Jan 05 '11 16:01

Vik


1 Answers

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
like image 189
Vik Avatar answered Oct 19 '22 02:10

Vik