I load this JS as a separate file, so it is then available after page has completely loaded :
//now load the values from the retrieved table, after a change initiated by user
$(document).change(function() {
//all formulae go below here:
// Ordered trays formula
$('table.gt-table tbody tr').each(function() {
var tray = 0;
var ordcell = 0;
var traycode= $(this).find("td.gt-col-mygrid1-trays_code div").html();
var ordcells= $(this).find("td.gt-col-mygrid1-ordered_cells div").html();
if (parseInt(traycode) >0) {
tray = parseInt(traycode);
} else {
tray = 0;
}
if (parseInt(ordcells) >0) {
ordcell = parseInt(ordcells);
} else {
ordcell = 0;
}
if (tray > 0 && ordcell > 0) var ordtrays = ordcell/tray;
if (ordtrays > 0){
$(this).find("td.gt-col-mygrid1-ordered_trays div").html(ordtrays);
}
});
// end Ordered trays formula
alert("boo");
}); // end the window change function
But it only works happily in Chromium. Both Opera and Firefox never fire ‘boo’ when the document is edited (it’s a Sigma grid that has editable cells).
Any ideas?
I believe the
changeevent ondocumentis a new thing as of the HTML5 specification (I can’t find it in DOM2 Events [which defineschangeforinput,textarea, andselect], DOM2 HTML, or DOM3 Events), and although it’s mentioned by the HTML5 spec, it’s not specified at all as far as I can see. So I suspect it’s not widely-supported (yet?).