0

Okay, once again I run into a snag with the jQuery uniform themes. http://uniformjs.com/ I am cloning rows with text inputs, drop downs, and buttons to add (clone) or remove rows. The problem is that once I clone a row, you can't change the drop down select on the new row. If I disable the uniform function it works.

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

Here is my code. Uniform update doesn't seem to work either.

//
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();
});
//

This is very similar to my issue, but didn't solve my problem. jquery cloning a block of element. select element acting weired

Community
  • 1
  • 1
triplethreat77
  • 1,276
  • 8
  • 34
  • 69

1 Answers1

0

You have to add uniform to those specific new elements. If you add uniform to an element, then add it again to the same element it will break. You want to try something like:

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

or just:

$("#newID select").uniform();
mathius1
  • 1,381
  • 11
  • 17