每次在我的表中克隆一行时,我都需要初始化我的自动完成字段。到目前为止,仅在页面加载时初始化我的第一行。这是我的代码http://jsfiddle.net/4XZMb/951/
function addRow(){
var numberExistingRows = 1;
// use "ADD" button to add new row
$('#add_row').click(function() {
// keep track of number of rows for input names
numberExistingRows++;
// clone a row
var $row = $('.dataRow:last').clone();
$row.find('.deleteRow').click(deleteRow);
// strip previous values and fix names of inputs
$row.find('input').each(function() {
var $input = $(this); // cache this input into jQuery object in lieu of using $(this) in below functions for clarity and performance
$input.val(""); // reset value to none
// fix names
var thisInputName = $input.attr('id');
$input.attr('id', thisInputName);
});
$('#tableSo').append($row);
return false;
});
}