Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery datepicker highlight specific dates fetched from ajax
    primarykey
    data
    text
    <p>I am using jquery date picker (<a href="http://api.jqueryui.com/datepicker/" rel="nofollow">http://api.jqueryui.com/datepicker/</a>) in my page. In the page I have a dropdown for program list. Beside the dropdown there is a textbox on clicking which will open the datepicker. I select the any program from dropdown and fire an ajax to fetch program dates .I am able to high light those dates in the datepicker when the user clicks the textbox. </p> <p>Now my problem is if I select any program whose dates is available then the datapicker is highlighted. For second time for other program which program date is not available still highlighted. I am using beforeShowDay() method to highlight specific dates.</p> <p>The main problem which I am able to debug is the javascript variable in my case "datesArray" is not reset inside the beforeShowDay() method each time I call ajax.</p> <p>Here is my code </p> <pre><code>$("#resourceId").change(function(){ var datesArray=[]; $.ajax({ url : '/aptcare/getscheduledate.action', data : "resourecid="+$(this).val(), method : "POST", async : false, success : function(data) { strarr=$.trim(data).split(","); for(var i =0;i&lt;strarr.length;i++){ datesArray.push(strarr[i]); } } }) console.log("dates array: "+datesArray); $('.datepicker').datepicker({ dateFormat: "dd/mm/yy", changeMonth: true, changeYear: true, beforeShowDay: function(date) { var theday = date.getDate() +'/'+ (date.getMonth()+1)+ '/' +date.getFullYear(); console.log("to highlight array: "+datesArray); return [true,$.inArray(theday, datesArray) &gt;=0?"Highlighted":'']; } }); }) </code></pre> <p>Here are the console logs</p> <p>For the first case dates array: "12/11/2013,12/11/2013,22/11/2013"</p> <p>and to highlight array: "12/11/2013,12/11/2013,22/11/2013"</p> <p>For the second case dates array:</p> <p>and to highlight array: "12/11/2013,12/11/2013,22/11/2013"</p> <p>That is "datesArray" is not reset.</p> <p>Thank you advance for your help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload