微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

jquery – 动态表上的colResizable不起作用

我有一个动态表,用户可以添加行或列,我还使用colResizable使用户可以灵活调整列的大小.虽然我添加了这个插件,但它不适用于新创建的单元格.
这是我的来源

$(document).ready(function() {
   $( "#container table" ).colResizable({ liveDrag : true });
   //... Other stuffs
}

这个函数用来创建列

function insert_column(element,position)
{
   element.parent().parent().find('tr').each(function() {
      var index = 0;
      $(this).find('td').each(function() {
         if (index == position)
         {
             $(this).after('

如果你想要,可能会认为这是因为一些CSS,这是我对#container和table里面唯一的CSS

#container {
    float: left;
    width:800px;
    height:100%;
    overflow:hidden;
    padding: 7px;
    border: 2px #BBB dashed;
}
#container table {
    width: 100%;
    table-layout: fixed;
    background-color:#FCFCFC;
}
#container td {
    border-spacing: 2px;
    min-height: 17px;
    min-width: 50px;
    border: 1px #CCC dotted;
}

奇怪的是,如果我评论删除colResizable,它可用于添加列,但如果我启用它,则添加列但不可见,无法调整大小.
任何帮助将不胜感激.

最佳答案
参考:
https://github.com/alvaro-prieto/colResizable/issues/2#issuecomment-5198584

//disable the plugin first    
$( "#container table" ).colResizable({ disable : true });

insert_column();

//Re-init the plugin on the new elements
$( "#container table" ).colResizable({ liveDrag : true });

原文地址:https://www.jb51.cc/html/426846.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐