开发者

how to pass array value from model to jquery datepicker?

I am trying to highlight days on the calendar. The highlighted days are from the v开发者_开发知识库iew 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


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"];
 }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜