George George - 8 months ago 33
jQuery Question

JQuery background color change not showing immediately in Chrome

In the following code, on Chrome, the background color change does not show until after the confirm is answered:

$('#ac_row_'+ac_table_row).children('td').css('background-color','#ffc3c3');
var agree=confirm( "Are you sure you want to delete this aircraft?" );


In Firefox and I.E. the color changes immediately and shows under the confirm modal dialog box. How do I get the background color to update immediately on Chrome?

I found some similar questions, but they didn't seem to apply to my situation. In those cases the color change never happens at all on Chrome.

Answer

The best solution I can think of right now is deferring the confirm call;

$('#ac_row_'+ac_table_row).children('td').css('background-color','#ffc3c3');
var agree;
setTimeout(function() {
    agree=confirm( "Are you sure you want to delete this aircraft?" );
});

But then you have to wait the timeout to check for agree's value.