I am trying to add CSS to a cell after a record in my jQuery Datatable is updated. Basically to show the user that the update was successful.
I'm using a BLUR event to send the parameters over to the processing script:
$('#example1').on('blur', 'tr > td > .editForecast', function(e)
{
e.preventDefault();
var forecastnewval = $(this).val();
$.post('api/inlineEditProcess.php', {forecastnewval:forecastnewval}, function(data)
{
changeColor(); // calling this function
//$(this).css('background-color', 'green'); // I tried this but unsuccessful
});
});
I'm calling this function:
function changeColor()
{
$('#example1 tr > td > .editForecast').on('blur', function()
{
$(this).css('background-color', 'green');
});
}
At this point, the user can make the update. But they tab/click off the cell nothing happens. The function only works when they click back into the cell and then tab/click off of it.
I know it has something to do with the fact that I already have a BLUR event going when they initially click into the cell. The function then uses another BLUR event, which explains why they have to click into the cell twice for it work.
I need it to work on the first BLUR event.
As you will see in the initial BLUR event, I did add the code to change the CSS within the $.POST, but that was unsuccessful.
I know I cannot use 2 BLUR events, but I'm not sure what else I can use to get this to work.