Skip to content

Commit

Permalink
fixed issue: confirm & alert will not stopped in chrome.
Browse files Browse the repository at this point in the history
  • Loading branch information
ztree committed Sep 19, 2016
1 parent 72d75de commit 17bd8d3
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 10 deletions.
6 changes: 5 additions & 1 deletion demo/cn/exedit/async_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@
}
function beforeRename(treeId, treeNode, newName) {
if (newName.length == 0) {
alert("节点名称不能为空.");
setTimeout(function() {
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
zTree.cancelEditName();
alert("节点名称不能为空.");
}, 0);
return false;
}
return true;
Expand Down
17 changes: 13 additions & 4 deletions demo/cn/exedit/edit_super.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,14 @@
showLog("[ "+getTime()+" beforeEditName ]     " + treeNode.name);
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
zTree.selectNode(treeNode);
return confirm("进入节点 -- " + treeNode.name + " 的编辑状态吗?");
setTimeout(function() {
if (confirm("进入节点 -- " + treeNode.name + " 的编辑状态吗?")) {
setTimeout(function() {
zTree.editName(treeNode);
}, 0);
}
}, 0);
return false;
}
function beforeRemove(treeId, treeNode) {
className = (className === "dark" ? "":"dark");
Expand All @@ -77,9 +84,11 @@
className = (className === "dark" ? "":"dark");
showLog((isCancel ? "<span style='color:red'>":"") + "[ "+getTime()+" beforeRename ]&nbsp;&nbsp;&nbsp;&nbsp; " + treeNode.name + (isCancel ? "</span>":""));
if (newName.length == 0) {
alert("节点名称不能为空.");
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
setTimeout(function(){zTree.editName(treeNode)}, 10);
setTimeout(function() {
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
zTree.cancelEditName();
alert("节点名称不能为空.");
}, 0);
return false;
}
return true;
Expand Down
6 changes: 5 additions & 1 deletion demo/en/exedit/async_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@
}
function beforeRename(treeId, treeNode, newName) {
if (newName.length == 0) {
alert("Node name can not be empty.");
setTimeout(function() {
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
zTree.cancelEditName();
alert("Node name can not be empty.");
}, 0);
return false;
}
return true;
Expand Down
17 changes: 13 additions & 4 deletions demo/en/exedit/edit_super.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,14 @@
showLog("[ "+getTime()+" beforeEditName ]&nbsp;&nbsp;&nbsp;&nbsp; " + treeNode.name);
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
zTree.selectNode(treeNode);
return confirm("Start node '" + treeNode.name + "' editorial status?");
setTimeout(function() {
if (confirm("Start node '" + treeNode.name + "' editorial status?")) {
setTimeout(function() {
zTree.editName(treeNode);
}, 0);
}
}, 0);
return false;
}
function beforeRemove(treeId, treeNode) {
className = (className === "dark" ? "":"dark");
Expand All @@ -77,9 +84,11 @@
className = (className === "dark" ? "":"dark");
showLog((isCancel ? "<span style='color:red'>":"") + "[ "+getTime()+" beforeRename ]&nbsp;&nbsp;&nbsp;&nbsp; " + treeNode.name + (isCancel ? "</span>":""));
if (newName.length == 0) {
alert("Node name can not be empty.");
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
setTimeout(function(){zTree.editName(treeNode)}, 10);
setTimeout(function() {
var zTree = $.fn.zTree.getZTreeObj("treeDemo");
zTree.cancelEditName();
alert("Node name can not be empty.");
}, 0);
return false;
}
return true;
Expand Down

0 comments on commit 17bd8d3

Please sign in to comment.