将参数传递给原型函数

时间:2017-09-14 16:18:55

标签: javascript editablegrid

我正在尝试将editablegrid与多个表一起使用。为此,我有一个包含所有数据库表和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);    
};

0 个答案:

没有答案