使用jquery BlockUI插件阻止表行

时间:2012-07-30 10:07:12

标签: jquery jquery-ui

我正在尝试阻止表格行,但我无法这样做。我正在使用jquery插件,blockUI。

我的代码:

var dis_tr = $("input[name=abc]").closest('tr')
dis_tr.block({message: null});

任何人都可以帮助我吗?

2 个答案:

答案 0 :(得分:4)

问题是,在表格的情况下,除了td元素之外我们不能写任何东西。我们不能阻止整行。而不是这个,我们必须阻止每个td元素。为此,我编写了使用blockUI的阻塞/解除阻塞函数的新函数。

// Functions added to block/unblock table rows by using blockUI jquery library
$.fn.block_row = function(opts) {
    row = $(this)
    height = row.height();
    $('td, th', row).each(function() {
        cell = $(this);
        cell.wrapInner('<div class="holderByBlock container" style="width:100%; height: ' + height + 'px; overflow: hidden;"></div>');
        cell.addClass('cleanByBlock');
        cell.attr('style', 'border: 0; padding: 0;')
        $('div.holderByBlock', cell).block(opts);
    })
};

$.fn.unblock_row = function(opts) {
    row = $(this)
    $('.cleanByBlock', row).each(function() {
    cell = $(this);
    $('div.holderByBlock', cell).unblock({
        onUnblock: function(cell, opts) {
            this_cell = $(cell).parent('td, th');
            this_cell.html($('.holderByBlock', this_cell).html());
            this_cell.removeAttr('style');
            this_cell.removeClass('cleanByBlock');
        }
    });
    })
};

答案 1 :(得分:-2)

控制台中是否有错误?我从来没有使用过blockUI,所以我怀疑我会有多大的帮助,但只是从我看来我建议尝试这个:

var dis_tr = $('input[name="abc"]').closest('tr');
dis_tr.block({message: null});