Looks like your issue rises from the fact that you have too many globals and that your code is not modular.
One solution would be to write your grid.js file in a way that's exposing a Grid component which can be instanciated and which encapsulates it's logic, so that the index.html page can create independent Grid component instances.
You can think of your grid or any UI component as re-usable components such as native <select> element.
What could you do with 2 select elements in the same page?
index.html
$(function () {
var $select1 = $('#select-1'), //this could be staffGrid = new Grid('#staff-grid')
$select2 = $('#select-2');
//Make a parallel with the change event and your gridLoadComplete event.
//gridLoadComplete should be fired by your grid component itself and your component
//should allow to listen to those events.
//It could be staffGrid.on('loadComplete', function () { staffGrid.getValue(); });
$select1.change(function () {
$select1.val(); //access select1 value
});
$select2.change(function () {
$select2.val(); //access select2 value
});
});
As you can see in the exemple above, we invoke the same val function to get the value, but against different instances which allows us to get the value we want without duplicating the val function's logic.
grindLoadComplete()from index.html, but have it grid.js linked to staffGrid.html and teacherGrid.html, correct? Try linking grid.js to index.html. These are three separate files that won't share sources, unless you have it called by a fourth file where it combines the three (not with frames, that won't work).grid.jsto index.html. Bcoz getValue() function returns different values in staffgrid & studentgrid.html