vakata / jstree

jquery tree plugin
http://jstree.com
MIT License
5.15k stars 1.38k forks source link

Issue with CRRM Plugin #188

Closed ravina closed 12 years ago

ravina commented 12 years ago

i have a jstree configure with crrm and context menu plugin.

In the context menu i am configuring the rename menu item

function customMenu(node) { // The default set of all items var items = { renameItem: { // The "rename" menu item label: "Rename", action: function () { $("#CompanyTree").jstree("rename"); } } }; return items; }

i bound the rename_node to the jstree

}).bind('rename_node.jstree', function (e, data) { // var newname = data.rslt.name;

    if (newname != '')
    {
        var ServiceBundle = new Object();
        ServiceBundle.AccountID = CurrentCompanyID;
        ServiceBundle.ServiceBundleID = data.rslt.obj.attr("id");
        ServiceBundle.ServiceName = data.rslt.name;
        ServiceBundle.EditedBy = repName;

        $.ajax({

            type: "POST",
            url: "../shared/asyncservices/BPM/Bpm.asmx/UpdateServiceBundle",
            data: "{serviceBundle:" + JSON.stringify(ServiceBundle) + "}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            dataFilter: function (data) { return ajaxDFilterStr(data); },
            success: function (msg)
            {
                alert("updated succesfully");
            }

        });

if i click on the tree node (select the node first) and then right click and select rename context menu rename working fine. but if i directly right click on the node and select rename context menu, jstree throwing and js exception in the crrm plugin section. because obj is set to false. please help

_fn : { _show_input : function (obj, callback) { obj = this._get_node(obj); var rtl = this._get_settings().core.rtl, w = this._get_settings().crrm.input_width_limit, w1 = obj.children("ins").width(), w2 = obj.find("> a:visible > ins").width() * obj.find("> a:visible > ins").length, t = this.get_text(obj), h1 = $("

", { css : { "position" : "absolute", "top" : "-200px", "left" : (rtl ? "0px" : "-1000px"), "visibility" : "hidden" } }).appendTo("body"), h2 = obj.css("position","relative").append(

vakata commented 12 years ago

You need to pass a second argument, as you can see here: http://www.jstree.com/documentation/contextmenu

Use: "action" : function (obj) { this.rename(obj); } Or: "action" : function (obj) { $("#CompanyTree").jstree("rename", obj); }