I am using jQuery to add a row to a table using input / select. I have a pattern row that is displayed: none, and to add a new row, I duplicate it and pass it at the end of the tbody of my table. Some code:
CSS:
.template { display: none; } .regle { display: block; }
PHTML:
<table class='w100' cellspacing='0' cellpadding='0' id='listTable'> <thead> <tr> <th>foo</th> <th>bar</th> <th>foobar</th> </tr> </thead> <tbody> <tr class="template"> <td> <?php echo $this->form->foo->renderViewHelper(); ?> <?php echo $this->form->foo->renderErrors(); ?> </td> [ ... ] </tr> </tbody> </table>
jQuery:
$("#ajout_regle").click(function(){ $( ".template" ) .clone() // Edit : I forgort it when I copy / past my code ! .first() .appendTo( "#listTable tbody" ) .addClass('regle') .find("input[type='text']").val(""); });
In IE8, it works very well, the line is correctly added to it and displayed correctly. But in FF, the entire row is displayed in the first column, and the rest of the table is empty ... I think the display: none / block has something to do with it, but I donβt know why.
source share