我正在尝试将可编辑网格与多个表一起使用。为此,我有一个包含所有数据库表和 onchange 的选择框,我希望它将表名传递给原型函数,以呈现新表。变量 _tableNames 在原型函数中始终未定义。我怎样才能传递那个变量?
var _tableNames;
/* passing tablename change */
$(document).ready(function() {
// Monitor your selects for change by classname
$('#dbtables').on('change', function() {
// Save the place increment and value of the select
_tableNames = $(this).val();
console.log(_tableNames);
datagrid = new DatabaseGrid();
});
});
// Select table to edit
DatabaseGrid.prototype.fetchGrid = function(_tableNames) {
// call a PHP script to get the data
console.log(_tableNames);
if(typeof _tableNames === "undefined"){
alert(_tableNames);
_tableNames='demo';
}
url="loaddata.php?db_tablename="+_tableNames;
this.editableGrid.loadJSON(url);
};