MVC - jQuery Datepicker for displaying events

I am currently creating an MVC application and am using the jQuery UI Datepicker http://jqueryui.com/demos/datepicker/

for booking events.

I would like to display all available event dates in a Datepicker. Is there a way to reset the datepicker to make eventdates only clickable or just highlight events. Any way to pass dates to datepicker? Any experience with this?

Thanks in advance

+5
source share
2 answers

, beforeShowDay DatePicker http://jqueryui.com/demos/datepicker/#event-beforeShowDay. , , , : - :

$('.selector').datepicker({
    beforeShowDay: function(date) { 
        for(i = 0; i < arrayOfCalendarEventDatesYouProvide.length; i++) {
            if(date.getMonth() == arrayOfCalendarEventDatesYouProvide[i].getMonth()
            && date.getDay() == arrayOfCalendarEventDatesYouProvide[i].getDay()
            && date.getYear() == arrayOfCalendarEventDatesYouProvide[i].getYear())

            //matched a day in the array, turn of date in calendar if you
            //don't want it pickable
            return [false, 'some-css-to-indicate-a-match'];
        }

        //if you get this far, no matches
        return [true, ''];
    }
});
+2

, : http://jqueryui.com/demos/datepicker/#min-max

, , , , , , min/max .

, , !

0

All Articles