views:

1461

answers:

2

I am using beforeShowDay to highlight special days in my jQuery datepicker. The only way I am able to change the background is to use the '!important' tag in my css class. This works perfectly for all days except 'today'. The css does not change the background color, only the border.

my css:

.genEvent a
{
border:solid 1px #DC143C !important;
background: #9696BA url(ui-bg_flat_75_9696BA_40x100.png) 50% 50% repeat-x !important;
}
+2  A: 

You could try qualifying the selector further.

For example:

body contentDiv .genEvent a
{
    border:solid 1px #DC143C !important;
    background: #9696BA url(ui-bg_flat_75_9696BA_40x100.png) 50% 50% repeat-x !important;
}

If that works you may be able to remove the other !important, which is worth avoiding as it's a bit of an antipattern.

ilivewithian
Its worth mentioning that the jQuery UI uses a .ui-datepicker-today or .ui-datepicker-currentDay - .ui-datepicker-currentDay.genEvent, .ui-datepicker-today.genEvent - the jQuery datepicker css also uses a !important though - so you'll need to !important to get over it.
gnarf
A: 

I found this here... might be of some help to you.

Why don't u use datepickers functionality to highlight special days? I use an inline datepicker as well and showing special days works just fine. I use something similar to:

$("#mnu_calendar").datepicker({
  ... other options
  beforeShowDay: function(thedate) {
    var theday    = thedate.getDate();
    if( $.inArray(theday,specialDays) == -1 )
      return [true,""];
    return [true, "specialDate"];
  },
  ... more options
});

specialsDays is my array with special days in this month e.g. [3, 12, 24]. "specialDate" is the CSS class name datepicker will add to the special days, so you can make them look anyway you want

Raithlin
I am using datepickers functionality to highlight days, just like your example above. In your specialDate class, are you able to override the background when the special day today? I realize the problem might be that I'm using a png as the background for each day instead of a color (png as background comes from my theme from UI Themeroller)
Bjorn
I'm not using it - as I said, I found that on the net. Have you tried using CSS class datepicker_today in conjunction with your .genEvent class? Perhaps by combining both you can override the background...
Raithlin