views:

32

answers:

1

Hi Jon,

I am trying to highlight days on the calendar. The highlighted days are from the view model(IEnumerable type). My code is as follows:

<script type="text/javascript">
 var datesArray = new Array();
   for (var item in Model) { 
     datesArray[datesArray.length] = "<%= item.PerformanceDate.Day %>";
   }
  $(document).ready(function()  {

   // Datepicker
   $('.datepicker').datepicker({
     inline: true,
     beforeShowDay: function (date) {
        var theday = date.getDate();
        if ($.inArray(theday, datesArray) <0) return [true, ""];
           return [true, "specialDate"];
        }

   });
});

Please let me know whats wrong with my code...

Thanks a Lot!! Anusha

A: 

This part looks wrong:

 if ($.inArray(theday, datesArray) <0) return [true, ""];
           return [true, "specialDate"];
        }

You should probably use {} when using an if statement instead of relying on the single line if statement check. Also, what error are you getting back? As for the code, I might suggest this instead:

 beforeShowDay: function (date) {
        var theday = date.getDate();
        if ($.inArray(theday, datesArray) <0) {
           return [true, ""];
        }
        return [true, "specialDate"];
 }
Organiccat
The if part works fine...it says item does not exist in the context. I am trying to access the Model properties to get an array of dates
anusha