vrao
vrao

Reputation: 645

customize contextmenu and icon on jstree

I would like to change default contextmenu and customize the create function with submenus: create service and create application. Then I would also like to associate icons with the service and application submenus.

I searched available solutions on stackoverflow and modified it to suit my requirements. But it does not work. So far, when I click on submenu the alert box is displayed. But the create node does not work. The icons are not displayed either.

Can someone please tell me how to fix this?

  "contextmenu" : {
    items : { b
        "create" : {
            "separator_before"  : false,
            "separator_after"   : true,
            "label"             : "Create",
            "action"            : false,
            "submenu" :{
                "create_service" : {
                    "seperator_before" : false,
                    "seperator_after" : false,
                    "label" : "service",
        "icon": "service.png",
                    action : function (obj) {
            alert("creating service");
                            this.create(obj, "last", {"attr" : {"rel" : "service"}});
                    }
                },
                "create_application" : {
                    "seperator_before" : false,
                    "seperator_after" : false,
                    "label" : "app",
        "icon": "app.png",
                    action : function (obj) { 
            alert("creating app");                              
                            this.create(obj, "last", {"attr" : { "rel" : "application"}});
                    }
                }
            }
        }
    }
  }

Upvotes: 3

Views: 8545

Answers (2)

Anoop
Anoop

Reputation: 859

Use full path for the icon image, like this

icon: "/Content/images/deleteIcon.gif"

Upvotes: 0

Wietse
Wietse

Reputation: 370

check line 2, and remove the "b":

items : { b

As an example, a snippet of my contect menu (maybe this helps):

"contextmenu": {
    "items": {
        "create" : false,
        "ccp" : false,
        "rename" : false,
        "remove" : {
            "label" : " Delete",
            "icon" : "/images/icon/cross.png"
        }
    }
},

Upvotes: 3

Related Questions