0

使用 JQuery EasyUi 树时,我加载了一个带有选中节点的数组。我的 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){...});  

                }               

            });
        });
4

2 回答 2

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>
于 2013-10-16T16:09:12.383 回答
0

非常感谢新手兰博 :)

我做了一些更改以使其正常工作:

<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>
于 2013-10-17T22:25:32.207 回答