2012-07-30 37 views
1

我想阻止表行,但我无法这样做。我正在使用jquery插件,blockUI。块表行使用jQuery BlockUI插件

我的代码:

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

谁能帮助我?

回答

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'); 
     } 
    }); 
    }) 
}; 
+0

代码可能在复选框中存在问题。查看https://groups.google.com/forum/#!topic/jquery-en/cPlArW6fMT0 – RockResolve 2013-10-07 19:30:24

+0

它有一个可怕的影响(至少在我的opts中),它会阻止每个单元格,所以它会在每个单元格中显示一个微调。它和使用$(“td,th”,row).block(opts);直接,不是吗? – Marc 2018-02-01 08:51:21

-2

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

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

控制台上没有错误 – RAJ 2012-07-30 10:21:49