2013-01-16 36 views
0

好的,我再次遇到了jQuery统一主题的障碍。 http://uniformjs.com/我使用文本输入克隆行,下拉列表以及添加(克隆)或删除行的按钮。问题是,一旦我克隆了一行,就无法更改新行上的下拉选择。如果我禁用它的统一功能,它的工作。克隆的drop drop不能与jQuery一起使用统一主题

<!---<script type="text/javascript" charset="utf-8"> 
    $(function(){ 
    $("input:text, input:file, select, textarea, input:button").uniform(); 
    }); 
</script>---> 

这是我的代码。统一更新似乎也不起作用。

// 
id=0; 
$("table#customers_tab img.remove").live("click", function (event) { 
     $(this).parents("tr").remove(); 
    var remove_id = event.target.id; 

    var index = remove_id.substring(6); 

    var table = document.getElementById("customers_tab"); 
    for(var i=parseInt(index); i<table.rows.length;i++){ 
    $($('table#customers_tab tr')[i]).find("img.add").attr("id","add"+i); 
    $($('table#customers_tab tr')[i]).find("img.remove").attr("id","remove"+i); 

    } 

    }); 

$("table#customers_tab img.add").live("click", function (event) { 
     id++; 
     var master = $(this).parents("table#customers_tab"); 
     var add_id = event.target.id; 

    var index = add_id.substring(3); 

    var prot = $($('table#customers_tab tr')[index]).clone(); 
    var incr = parseInt(index)+1; 

    prot.find("img.add").attr("id","add"+incr); 

     $('.feature').live('change',function(){ ////SOLUTION HERE 
      $.uniform.update("select"); //// 
     }); //// 

    $($('table#customers_tab tr')[index]).after(prot); 
    var table = document.getElementById("customers_tab"); 

    for(var i=incr+1; i<table.rows.length;i++){ 
    $($('table#customers_tab tr')[i]).find("img.add").attr("id","add"+i); 
    $($('table#customers_tab tr')[i]).find("img.remove").attr("id","remove"+i); 

    } 
    $.uniform.update(); //NOT WORKING 
    }); 
$("#delAllCustomers").live("click", function (event) { 
    $("#customers_tab").children().remove(); 
}); 
// 

这与我的问题非常相似,但没有解决我的问题。 jquery cloning a block of element. select element acting weired

回答

0

你必须为这些特定的新元素添加统一。如果您将统一元素添加到元素中,则将其重新添加到将会中断的元素中。你想尝试类似:

$("#newID1 input:text, #newID2 input:file, #newID3 select, #newID4 textarea, #newID5 input:button").uniform(); 

或者只是:

$("#newID select").uniform(); 
+0

好了,上面的代码工作现在。我编辑它,谢谢你的输入。 :d – triplethreat77