使用jquery对数据表排序后捕获事件

发布于 2024-10-11 17:57:33 字数 912 浏览 2 评论 0原文

我遇到了 datatable (http://www.datatables.net)、jQuery 和 Firefox 的问题。

我有一个 jQuery 数据表 (id="equipmentList"),上面有一个按钮:

<html:button styleId="deleteButton" property="delete" value="<%= buttonDelete %>" disabled="disabled" />

当我对数据表上的列进行排序时,我想禁用一个按钮(按钮 deleteButton< /code>),所以我写了这段代码:

$('#equipmentList th').click( function() {
    hideButtonEditAndDelete();
});

function hideButtonEditAndDelete() {
    $("#modifyButton").attr("disabled", "disabled");
    $( "#deleteButton" ).attr("disabled", "disabled");

//fix for firefox

if($.browser.mozilla){
    $("#modifyButton").addClass('ui-state-disabled');
    $("#deleteButton").addClass('ui-state-disabled');
}}

一切都很顺利,直到排序结束,因为之后,我的按钮由 jQuery 启用;或其他东西。所以我正在排序顺序末尾寻找捕获事件以禁用我的按钮

I've an issue with a datable (http://www.datatables.net), jQuery and Firefox.

I've a jQuery datatable (id="equipmentList") with a button above:

<html:button styleId="deleteButton" property="delete" value="<%= buttonDelete %>" disabled="disabled" />

When i'm sorting a column on the datatable, i want to disable a button (the button deleteButton), so I wrote this code :

$('#equipmentList th').click( function() {
    hideButtonEditAndDelete();
});

function hideButtonEditAndDelete() {
    $("#modifyButton").attr("disabled", "disabled");
    $( "#deleteButton" ).attr("disabled", "disabled");

//fix for firefox

if($.browser.mozilla){
    $("#modifyButton").addClass('ui-state-disabled');
    $("#deleteButton").addClass('ui-state-disabled');
}}

Everything goes well until the sort is ending because, after, my button is enabled by jQuery; or something else. so I'm looking for capture event at the end of sorting order to disable my button

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

熟人话多 2024-10-18 17:57:33

每次重绘表格时都会发出一个回调,并且可以在 fnDrawCallback 上访问:

$('#someTable').dataTable({
        "fnInitComplete": function() {
            // after table is intialised do something here
        },
        "fnDrawCallback": function() {
            // after table is redrawndo something here
            console.log("redrawn");
        },
        "bDestroy": true,
        "bAutoWidth": false,
        "bPaginate": false,
        "sScrollY": "242px",
        "bLengthChange": false,
        "bInfo": false,
        "bFilter": false,
        "aaSorting": [[2, 'asc']],
        "aoColumns": [
            { "sSortDataType": "dom-checkbox", "sWidth": "3%" },
            { "bSortable": true, "sWidth": "8%" },
            { "bSortable": true, "sWidth": "10%" },
            { "bSortable": true, "sWidth": "15%" },
            { "bSortable": true, "sWidth": "8%" },
            { "bSortable": true, "sWidth": "9%" },
            { "bSortable": true, "sWidth": "6%" },
            { "bSortable": false, "sWidth": "2%" },
            { "bSortable": false, "sWidth": "7%" },
            { "bSortable": false, "sWidth": "13%" },
            { "bSortable": false, "sWidth": "2%" },
            { "bSortable": false, "sWidth": "7%" },
            { "bSortable": false, "sWidth": "10%" }
        ]
    });

有关回调的更多信息,请参见:

http://datatables.net/usage/callbacks

There is a callback that is made every time that the table is redrawn and can be accessed on the fnDrawCallback:

$('#someTable').dataTable({
        "fnInitComplete": function() {
            // after table is intialised do something here
        },
        "fnDrawCallback": function() {
            // after table is redrawndo something here
            console.log("redrawn");
        },
        "bDestroy": true,
        "bAutoWidth": false,
        "bPaginate": false,
        "sScrollY": "242px",
        "bLengthChange": false,
        "bInfo": false,
        "bFilter": false,
        "aaSorting": [[2, 'asc']],
        "aoColumns": [
            { "sSortDataType": "dom-checkbox", "sWidth": "3%" },
            { "bSortable": true, "sWidth": "8%" },
            { "bSortable": true, "sWidth": "10%" },
            { "bSortable": true, "sWidth": "15%" },
            { "bSortable": true, "sWidth": "8%" },
            { "bSortable": true, "sWidth": "9%" },
            { "bSortable": true, "sWidth": "6%" },
            { "bSortable": false, "sWidth": "2%" },
            { "bSortable": false, "sWidth": "7%" },
            { "bSortable": false, "sWidth": "13%" },
            { "bSortable": false, "sWidth": "2%" },
            { "bSortable": false, "sWidth": "7%" },
            { "bSortable": false, "sWidth": "10%" }
        ]
    });

More info on callbacks here:

http://datatables.net/usage/callbacks

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文