vakata / jstree

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

edit callback not triggered #2548

Closed NoelSMartin closed 3 years ago

NoelSMartin commented 3 years ago

I have a context menu plugin that triggers the edit on a node - this works fine.. the input box is created However on blur of the input box nothing happens. `appAdmin_squadlog.initContextMenu = function(){ $.contextMenu({ selector: '#layout_appAdmin_squadlog_layout_panel_main .jstree-node, #layout_appAdmin_squadlog_layout_panel_main .w2ui-panel-content', build: function($trigger, e){ return { callback: function(key, options) { switch (key) { case 'reload': appAdmin_squadlog.tree.load_node('#'); appAdmin_squadlog.tree.load_all(); break; case 'expand-all': appAdmin_squadlog.tree.open_all(); break; case 'collapse-all': appAdmin_squadlog.tree.close_all(); break; case 'rename': appAdmin_squadlog.tree.edit(appAdmin_squadlog.tree.selected.id, function(node, status){ console.log(node); }); break; } }, items: { "new": {name: "New", items: { "new-region": {name: "Region"}, "new-market": {name: "Market", disabled: function(){return (appAdmin_squadlog.tree.selectedType != 'Region' || $trigger[0].nodeName != 'LI')}}, "new-cu": {name: "CU", disabled: function(){return (appAdmin_squadlog.tree.selectedType != 'Market' || $trigger[0].nodeName == 'DIV')}}, "new-tribe": {name: "Tribe", disabled: function(){return (appAdmin_squadlog.tree.selectedType != 'CU' || $trigger[0].nodeName == 'DIV')}}, "new-squad": {name: "Squad", disabled: function(){return (appAdmin_squadlog.tree.selectedType != 'Tribe' || $trigger[0].nodeName == 'DIV')}}, }}, "rename": {name: "Rename", disabled: function(){return (!appAdmin_squadlog.tree.hasSelection || $trigger[0].nodeName == 'DIV')}}, "delete": {name: "Delete", disabled: function(){return (!appAdmin_squadlog.tree.hasSelection || $trigger[0].nodeName == 'DIV')}}, sep1: "---------", "reload": {name: "Reload",}, "expand-all": {name: "Expand all",}, "collapse-all": {name: "Collapse all",}, } }

    }
});

}`

squadlog.txt

vakata commented 3 years ago

I can not help you without a demo - here is a fiddle demonstrating edit working properly: https://jsfiddle.net/bmLvuwe5/

Keep in mind you are calling the method wrong - the callback should be the third parameter, not the second.