【问题标题】:Jeditable + JmaskedInput + new dynamic fieldJeditable + JmaskedInput + 新动态字段
【发布时间】:2011-08-29 11:51:07
【问题描述】:

好的,

我正在使用 jeditable + jmaskedinput 来操作我的表格。

$(".edit_user").editable("save.php", { 

                    data: '{"84":"Test User","85":"Test User"," ":" "}',

                    type: "select",

                    onblur: "submit",



                });

在此之后,我想在我的表中添加一个新列。

$('table.schichtplan tr:first').append('<th><div class="add_user" id="xyz">User</div></th>');

我通过一个按钮在上面调用它;)

所以我添加了一个新的 TH 元素,但我无法通过 jeditable 对其进行编辑。

我的代码:

        $(".edit_employee").editable("save.php", { 

                data: some json,

                type: "select",

                onblur: "submit",

                placeholder: "Mitarbeiter"

            });



        $('#add_employee').click(function(){

            var tage = $('table.schichtplan tr').length-4;

            var sort_id = $('table.schichtplan').find('tr')[0].cells.length-1;

            var new_th = '<th><div id="plan_id:'+plan_id+';sort_id:'+sort_id+'" class="edit_employee">Mitarbeiter</div></th>';

            $('table.schichtplan tr:first').append(new_th);

        });         

这是我使用的顺序。嗯

编辑:

   $('th > div').live('mouseenter',function(){

                $(this).editable("save.php", { 

                    data: json,

                    type: "select",

                    onblur: "submit",

                    placeholder: "Mitarbeiter"

                });

            });

即使这样也行不通;(

【问题讨论】:

    标签: jquery jeditable html-table


    【解决方案1】:

    那是因为.editable() 正在使用.bind(),它只会影响 DOM 中已经存在的元素。尝试以下方法:

    $('th > div').live('mouseenter', function() {
        $(this).editable(...);
    });
    

    本质上,它观察任何th &gt; div 上的mouseenter 事件。当它发生时,它使div 元素可编辑。

    【讨论】:

    • 我试过这个,不起作用;(当我调用 .append() 部分时,我必须“重新加载”.editable?所以只需将完整的 edit_user.editable 部分添加到 .append( ) 部分?
    • 嗯...我可能不明白你的问题。您是否在单击按钮时添加列?
    • 是的,该列已添加(只是一个新的 th 元素)。我在第一篇文章中添加了更多代码。
    【解决方案2】:

    尝试使用这个,元素有class="edit":

    $(document).on('mouseenter','.edit', function() {
        $(this).editable('updatedata.php');
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多