如何在Jquery中取消绑定网格视图行单击事件

时间:2021-04-24 19:45:37

I need to unbind datagrid row click event,

我需要取消绑定datagrid行点击事件,

I have tried a lot using

我尝试过很多次

$.each(gridData, function (index, row) {
            if (row)
            {
                if (row["Islicense"].toString() == "false")
                {                    
                    $('.grid_table tr').each(function () {
                        var ballyDataGridRow = $(this);
                        if (ballyDataGridRow.attr('valuemember') == row["ComponentID"]) {
                            
                           // ballyDataGridRow.find("tr").unbind('click');
                            //ballyDataGridRow.find("tr").undelegate("click");
                           // ballyDataGridRow.find("tr").off("click");
                            //ballyDataGridRow.find('input').prop("disabled", true);
                           
                        }
                    });
                   
                   
                }
            }

        });

I have used unbind,undelegate,off, even its not working

我使用unbind,undelegate,off,甚至它不工作

1 个解决方案

#1


If your ballyDataGridRow has had a click attached, then there is no need for the find('tr') as that is the tr already.

如果你的ballyDataGridRow附加了一个点击,那么就不需要find('tr'),因为它已经是tr了。

e.g. use this instead

例如改用它

ballyDataGridRow.off("click");

or

ballyDataGridRow.unbind("click");

At the moment you are searching for a tr within each tr, which is like doing this:

目前你在每个tr中搜索一个tr,就像这样做:

$('.grid_table tr tr')

#1


If your ballyDataGridRow has had a click attached, then there is no need for the find('tr') as that is the tr already.

如果你的ballyDataGridRow附加了一个点击,那么就不需要find('tr'),因为它已经是tr了。

e.g. use this instead

例如改用它

ballyDataGridRow.off("click");

or

ballyDataGridRow.unbind("click");

At the moment you are searching for a tr within each tr, which is like doing this:

目前你在每个tr中搜索一个tr,就像这样做:

$('.grid_table tr tr')