1

我创建了一个函数,它将遍历动态克隆区域中的所有元素,以便用户可以在他们选择的任何位置插入新信息,或上下移动元素。除了ie7,它似乎在任何地方都可以正常工作。在 ie7 中:当我添加一行时,该行添加,但删除它之后的所有行(如果它不是最后一行);当我尝试删除动态创建的行时 - 该行不会删除。我知道删除按钮的单击事件正在被触发,并且在我输入的测试警报中显示了正确的 id。

//to insert a new row
$('#clone_').clone(true).attr({
    id:'row_'  + newID
    }).insertBefore('#tbl_row');    

// to delete a row:
alert(id);///just wanted to point out this is correct
$('#' + id).remove();

//to renumber the rows after remove or insert
for (i = newrow; i < lastrow; i++){
  renumberSection(i, i+1, 0);
}


function renumberSection(numero, numero_swap, numero_temp){
//temporarily name the row to be swapped
$('#row_'+ numero_swap).attr('id','row_'+ numero_temp);

//change the selected line to the swapped line number
$('#row_'+ numero).attr('id','row_'+ numero_swap);

//change the swapped line to the selected line number
$('#row_'+ numero_temp).attr('id','row_'+ numero).insertBefore('#row_'+ numero_swap); //sometimes it's insertAfter - but i'm trying to simplify the code

}
4

0 回答 0