2013-10-11 45 views
0

使用JQuery EasyUi樹時,我加載了一個帶有已檢查節點的數組。我的pb是我的onCheck函數在數據載入後被觸發,我想僅在單擊複選框時觸發onCheck方法JQuery EasyUi Tree: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

由於很多新手蘭博:)

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

<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> 
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> 
相關問題