Passing parameters to a prototyped function

59 Views Asked by At

I am trying to use editablegrid with multiple tables. For that, I have a select box with all database tables and onchange I want it to pass the tablename to a prototype function, in order to render the new table. The variable _tableNames is always undefined inside the prototype function. How can I pass that variable?

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

There are 0 best solutions below