2014-07-23 28 views
0

我想用Kendo Grid Control模板中的控件來使用Jquery,但jquery不起作用,也不會收到任何錯誤。Jquery沒有與Kendo Grid模板一起工作

$("#grid").kendoGrid({ 
      dataSource: { 
       type: "json", 
       transport: { 
        read: { 
         url: url, 
         dataType: "json", 
         type: "GET", 

        } 
       }, 
       pageSize: 50 
      }, 
      //height: 550, 
      groupable: true, 
      filterable: true, 
      sortable: true, 
      toolbar: kendo.template($("#template").html()), 
      pageable: { 
       refresh: true, 
       pageSizes: true, 
       buttonCount: 5 
      }, 
      columns: [{ 
       field: "ApplicantRefNo", 
       title: "Reference No.", 
       //width: 200 
      }, { 
       field: "FirstName", 
       title: "First Name" 
      }, { 
       field: "Mobile", 
       title: "Mobile" 
      }, { 
       field: "Address", 
       title: "Address" 
      }, 
      { 
       field: "Marks", 
       title: "Test Score" 
      }] 
     }); 
    } 

<script type="text/x-kendo-template" id="template"> 
       <div class="toolbar"> 

        <a id="btnSaveAll">Save All</a> 

       </div> 

</script> 

<script> 

    $(document).ready(function() { 

     $("#btnSaveAll").click(function() { 
         alert("ff"); 
      }); 
     }); 
</script> 

回答

1

試試這個..

$(document).on("click","#btnSaveAll", function(e){ 
    alert("ff"); 
}); 

感謝

0

我會說問題在於,在實際創建網格之前定義了click處理程序事件。可能嗎?

這裏檢查它:http://jsfiddle.net/OnaBai/8U6rg/5/

請嘗試:

​​

,並檢查警報顯示消息BtnSave:1

0

您可以使用jQuery '上' 方法綁定事件的DOM元素加載晚於綁定。

$("#btnSaveAll").on('click', function(e){ 
    alert("ff"); 
});