before.jstree called twice during drag and drop of a node in jquery -
i trying move nodes within the jstree(which build json_data).
when move node want display confirmation "are sure want move?". using following code.
$("#demo2").bind("before.jstree", function (e, data) { if(data.func == "move_node" && data.args[1] == false && data.plugin == "core") { if (confirm('are sure want move?') === false) { e.stopimmediatepropagation(); return false; } }
});
but "are sure want move?" confirm message displayed twice.
may know how fix ? using latest jstree,jquery commit.and not using crrm plugin.i using dnd plugin.
please advise.
regards, peri
thanks reply chris. tried still not working. alert appears twice here also. please advice. $("#demo2").bind("before.jstree", function(e, data) { try{ var flag = 1; var nodemoved = data.args[0].o; } catch(e){ flag = 0; } if (data.func == "move_node" && data.args[1] == false && data.plugin == "core" && flag == 1) { // alert(data.func + "---" + data.args[1] + "---" + data.plugin); if(!confirm("are sure want move?")) { e.stopimmediatepropagation(); return false; } } });
i haven't run myself, i've read issue on jstree user group. believe @ time solution create global javascript flag. once user has indicated yes/no key off prevent pop-ups. of course need clear flag afterwards don't suppress future move confirmation prompts.
also, i've noticed in multiple calls before.jstree data.func == "move_node" 1 of them has defined data.args[0].o (see _get_move description of objects used in jstree data). modify code alternative global flag (i've played haven't put in production ymmv):
if(data.func == "move_node" && data.args[1] == false && data.plugin == "core" && data.args[0].o != undefined) { // work goes here... }
Comments
Post a Comment