Okay, I know what it is... It's JQuery : var row; row = itemTable.$('tr.row_selected'); And it is crashing, telling me "Uncaught TypeError: undefined is not a function" Of course "undefined" doesn't tell me anything, but after a few days, I managed to figure out it was referring to the '$' I replaced it with the actual word "JQuery", but that still doesn't help.
See, the problem is that it doesn't work in project B, but worked in project A. Same script includes before my code. Same order. Same everything.
My initialization code looks like this, and works fine. I manually add a rows with "itemTable.fnAddData(..) " :
var itemTable; // global... no prob....
$(document).ready(function() {
// other stuff....
InitializeTable();
$('#scannedItemsList').find('tbody').on('click','tr',RowSelect); // add my click event to select a row
});
/* The Table has 7 columns */
function InitializeTable() {
var tableInit = {}; /* Build an initialization object */
/* Now, insert all the other settings needed for the initialization object */
tableInit.sPaginationType = "full_numbers";
tableInit.oLanguage = {
"sLengthMenu": "Display _MENU_ items per page",
"sZeroRecords": "No entries to display",
"sInfo": "Showing _START_ to _END_ of _TOTAL_ Items",
"sInfoEmpty": "Showing 0 to 0 of 0 items ","sInfoFiltered": "(filtered from _MAX_ Total items)"
};
> tableInit.aoColumns = [<br>
null, null, null,null, null, null, { "sClass" : "leftJust" } /* all 7 columns*/
];
/* And init the table, returning the table object into a global */
itemTable = $('#scannedItemsList').dataTable( tableInit);
}
!!!!!!!!!!!!!!!!! ODD... THE ABOVE JQUERY CODE WORKS, BUT THE ONE IN MY "RowSelect" CRASHES !!!!!!!!!!!
/* This was derived from the samples on this site...
and works in project A, but now, 3 months
later in project B, it is crashing JS */
function RowSelect() {
// remove ALL 'row_selected' end 'edit_mode' classes from the table
var row;
row = itemTable.$('tr.row_selected');
!!!!!! CRASH !!!!!!!!!
Does anyone have any idea why one works, and the other doesn't? Why it knows what "$" means on line 44 in my code, but suddenly doesn't know what "$" means on line 52, a function later?
This is really driving me to drink!
-Scotty