不能触发Alert();on Jqxgrid复选框

Cant trigger Alert(); on Jqxgrid Checkbox

本文关键字:on Jqxgrid 复选框 Alert 不能      更新时间:2023-09-26

我遵循这个http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/index.htm?%28arctic%29#demos/jqxgrid/checkboxcolumn.htm我想做的是,我试图捕捉复选框上的变化到目前为止,我已经这样做了,但下面不触发任何东西有人能告诉我我在这里错过了什么

jQuery('#jqxgrid').find('span').on("click",function() {
                    alert('i am here');
                });
jQuery('#jqxgrid').on("click",function() {
                        alert('This works but when i try to click on <span> that holds checkbox, it dont alert any thing other then this it works');
                    });

和我的HTML简单如下

<body class='default'>
        <div id="jqxgrid"></div>
    </body>

尝试使用事件委托如果您的元素是动态添加的:

$('body').on('click', '#jqxgrid span', function() {
    alert('i am here');
});

按评论,您可以使用; () :

jQuery('#jqxgrid').on("click", function() {                 
    var span = jQuery(this).find('.jqx-checkbox-check-checked');
});
I use this.
//=======> First I Define my element in the Jqxgrid, in my case one button...
myDataTable = $('#jqxgrid').DataTable({
            data: dataSet,
            columns: [
                      {
                          render: function ()
                          {
                              return '<button type="button" id="btnTest"></button>';
                          },
                          width: 50
                      },
                   .
                   .
                   .
                   .

//=======>Then, I catch the event 
   $('#jqxgrid tbody').on('click', '#AddTransportistas', function ()
        { alert('I am here'); 
});