javascript - can not set tooltip dynamically for each highlighted dates in datepicker -
i have done highlights dates using jquery datepicker calendar.my problem is, trying give tooltips each date highlighted can not achieve!.
the code tried,
beforeshowday: function(date) { var highlightdays=["2014-11-20", "2014-11-21", "2014-11-24", "2014-11-25"]; var whosebday=["mani-bday","john-bday","saro-bday","mikel-bday"]; var y = date.getfullyear().tostring(); // total year var m = (date.getmonth() + 1).tostring(); // month. var d = date.getdate().tostring(); // day //alert(m.length); if(m.length == 1){ m = '0' + m; } // append zero(0) if single digit if(d.length == 1){ d = '0' + d; } // append zero(0) if single digit //var currdate = y+'-'+m+'-'+d; (var = 0; < highlightdays.length; i++) { if($.inarray(y + '-' + (m) + '-' + d,disableddays) != -1) { //alert("i value"+i); homecoming [true, 'cssdate', 'today bday for:'+whosebday[i]]; } var day = date.getday(); homecoming [(day != 0), ''];//disable sundays } homecoming [true]; }
i guess problem i
value not increment in whosebday[i].
note : output is, mani-bday([0]) come dates. tell me wrong?
the error in using for
loop , $.inarray
inside. $.inarray
gives index of date if found or -1
otherwise. loop nail return
statement. performing 1 , 1 iteration. hence why i = 0
.
get rid of loop , homecoming true
if found corresponding index returned $.inarray
. refactoring little bit code:
beforeshowday: function(date) { var y = date.getfullyear().tostring(); // total year var m = (date.getmonth() + 1).tostring(); // month. var d = date.getdate().tostring(); // day if(m.length == 1){ m = "0" + m; } // append zero(0) if single digit if(d.length == 1){ d = "0" + d; } // append zero(0) if single digit var ymd = y + '-' + (m) + '-' + d; var = $.inarray(ymd, highlightdays); if (i != -1) { homecoming [true, "cssdate", whosebday[i]]; } var day = date.getday(); homecoming [day != 0, ''];//disable sundays }
see demo
javascript jquery
No comments:
Post a Comment