使用JQuery EasyUi Tree时,我加载一个带有已检查节点的数组。我的pb是我的onCheck函数在数据加载后被触发,我想只在我点击复选框时触发onCheck方法
文档说:“当用户点击复选框时会触发。” cf:http://www.jeasyui.com/documentation/tree.php
我不知道我的代码有什么问题。如果您对如何做到这一点有所了解,那就太好了:)
这是我的代码:
<script type="text/javascript">
//Enable Drag and drop
$(function(){
$('#tt').tree({
dnd: true,
url: 'get_activite_data.php',
cascadeCheck: true,
onLoadSuccess: function(node,data){
$('#tt').tree('expandAll')
},
onDrop: function(targetNode, source, point){
var targetNode = $('#tt').tree('getNode', targetNode);
.......
}
,
onCheck: function(node,checked){
$.messager.confirm('Confirm','I want to be fire only when user click manually the checkbox', function(r){...});
}
});
});
答案 0 :(得分:0)
试试这个......
var isLoadingTime = true;
....
if (isLoadingTime) {
return;
}
....
isLoadingTime = false;
我编辑了你的代码:
<script type="text/javascript">
var isLoadingTime = true;
//Enable Drag and drop
$(function(){
$('#tt').tree({
dnd: true,
url: 'get_activite_data.php',
cascadeCheck: true,
onLoadSuccess: function(node,data){
$('#tt').tree('expandAll')
},
onDrop: function(targetNode, source, point){
var targetNode = $('#tt').tree('getNode', targetNode);
.......
},
onCheck: function(node,checked){
if (isLoadingTime) {
return;
}
$.messager.confirm('Confirm','I want ... checkbox', function(r){...});
}
});
isLoadingTime = false;
});
</script>
答案 1 :(得分:0)
非常感谢新手Rambo:)
我做了一些改动以使其有效:
<script type="text/javascript">
isLoadingTime = true;
//Enable Drag and drop
$(function(){
$('#tt').tree({
dnd: true,
url: 'get_activite_data.php',
cascadeCheck: true,
onLoadSuccess: function(node,data){
$('#tt').tree('expandAll');
isLoadingTime = false;
},
onCheck: function(node,checked){
if (isLoadingTime) {
return;
}else{
//here the function to update db when user click manually
}
}
});
});
</script>