-1
我有jQuery中下面的代碼爲什麼var沒有更新?
var fila;
$(document).ready(function(){
acciones_filas('tbl_producto', 'acciones-activos', productoTable);
$("#id_producto").val(fila.nProCodigo);
}
function acciones_filas(tabla_id, acciones_id, tabla_objeto, fila)
{
//click on a row
$("#"+tabla_id+" tbody").on('click', 'tr', function(){
$("#"+acciones_id+" .btn").removeAttr('disabled');
if ($(this).hasClass('row_selected')) {
$(this).removeClass('row_selected');
}
else {
tabla_objeto.$('tr.row_selected').removeClass('row_selected');
$(this).addClass('row_selected');
}
if($('#'+tabla_id+' .row_selected').length < 1)
$("#"+acciones_id+" button").attr('disabled', 'disabled');
fila = tabla_objeto.fnGetData(this);
});
}
當我在一個表中的變量fila
一行單擊要保存選定行的值,但是當我打印出結果我得到和undefined
不包括'在acciones_filas'的'參數列表fila',它會成爲一個局部變量,並在影子全球'fila'功能。 – Teemu
對不起,我忘了刪除它。 – laviku
@Teemu解決了它,謝謝 – laviku