I have a simple function on click that toggles a div. It checks the classes to determine if it should remove the 'hilighted' state classes.
This fails to remove the holdhilite class:
function togglediv(id){
//alert('toggle id= '+id);
$("#"+id).toggle("fast");
if(window.location.hash.split("#")[1]==justtheid(id)){
var scr = document.body.scrollTop;
window.location.href = '#';
document.body.scrollTop = scr;
}
var trid = "tr_"+justtheid(id);
if($("#"+trid).attr('class')=='holdhilight rowhover'){
$("#"+trid).removeClass('holdhilight');
}
else{
$("#"+trid).addClass('holdhilight');
}
}
On the other hand, this works 100%:
function togglediv(id){
alert('toggle id= '+id);
$("#"+id).toggle("fast");
if(window.location.hash.split("#")[1]==justtheid(id)){
var scr = document.body.scrollTop;
window.location.href = '#';
document.body.scrollTop = scr;
}
var trid = "tr_"+justtheid(id);
if($("#"+trid).attr('class')=='holdhilight rowhover'){
$("#"+trid).removeClass('holdhilight');
}
else{
$("#"+trid).addClass('holdhilight');
}
}
Note the only difference is that alert being uncommented (i don't even want to tell you how long it took me to figure out this was the issue... lol)
So, what's the deal? why does waiting/clicking ok on the alert allow the class=='holdhilight rowhover' to match but when no alert, it does not (even though an alert in this spot says it DOES indeed match, but once the alert is in place, it works again... lol)
I've waiting in my browser 30 seconds before trying to close it, and that did nothing to fix it. It's not the script taking forever to run.
This is all wrapped in a ready() function anyway.
I'm in an ie8-specific enviro (intranet) using the latest 1.9