BackGround Color of element in a List Rows

farinacci

Member
I would like to see the BackGround color red if element in the list is null.
In element javascript onload/onblur event i have this code:

jQuery.each(rows, function(rowid, row) {

if (row.forecast___RatingIC === null || row.forecast___RatingIC === '' ) {

jQuery(row.forecast___RatingIC).css('background-color', 'red');
}
else {
jQuery(row.forecast___RatingIC).css('background-color', 'green');
}

})

why not work ? How to do?
Thanks
 
The element JS events only run in form/details view. Also, 'rows' doesn't exist, not sure where you are getting that from.

You'll need to handle the load event yourself. Create a ./components/com_fabrik/list_X.js (where X is your numeric list ID), and do ...

Code:
jQuery(document).ready(function(){
   jQuery('forecast___RatingIC').each(function(i, k) {
      if (jQuery(k).html().trim().length === 0) {
         jQuery(k).css('background-color', 'red');        
      }
      else {
         jQuery(k).css('background-color', 'red');
      }
   });
});

Note that you may have to change that trim() test, but it should work for most instances of an "empty" list cell. You can't just test for == "", ie. empty string, as it'll probably have spaces and line breaks. So html().trim() should get rid of blank space.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top