Note that there are some explanatory texts on larger screens.

plurals
  1. POHelp! How to make days enabled in UI datepicker after month change?
    primarykey
    data
    text
    <p>In my situation:</p> <p>I got the days which want to be enabled from ajax called. When I change the month ,I read the xml file vial ajax called and got the days of that month.How to make it out??</p> <p>thank you very much!!</p> <p>array variable to hold the days:</p> <pre><code>var $daysWithRecords = new Array() </code></pre> <p>function to load xml files:</p> <pre><code>function getDays(year,month){ $.ajax({ type: "GET", url: "users.xml", dataType: "xml", success:function(msg) { initDaysArray( $(msg) , year , month ); } }); } </code></pre> <p>function to initial the days array:</p> <pre><code>function initDaysArray( $xml , year , month ) { //alert(year+'-'+month); var dateToFind = year+'-'+month; var $myElement = $xml.find( 'user[id="126"]' ); dates = ''; $myElement.find('whDateList[month="'+dateToFind+'"]').find('date').each(function(){ $daysWithRecords.push(dateToFind+$(this).text()); dates += $(this).text() + ' '; }); console.log(dates); console.log($daysWithRecords.length) } </code></pre> <p>function to make the day available in array variable :</p> <pre><code>function checkAvailability(avalableDays){ var $return=false; var $returnclass ="unavailable"; $checkdate = $.datepicker.formatDate('yy-mm-dd', avalableDays); for(var i = 0; i &lt; $daysWithRecords.length; i++){ if($daysWithRecords[i] == $checkdate){ $return = true; $returnclass= "available"; } } return [$return,$returnclass]; } </code></pre> <p>datepicker part code to load and show days[ <strong>note: I am using the inline mode of datepicker</strong>]</p> <pre><code>$('#div').datepicker({ dateFormat: 'yy-mm-dd',defaultDate: '2010-09-01' , onChangeMonthYear: function(year, month, inst) { console.log(year); console.log(month); getDays(year,month); } , beforeShowDay: checkAvailability }); </code></pre> <p>and final my xml file:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;users&gt; &lt;user id="126"&gt; &lt;name&gt;john&lt;/name&gt; &lt;watchHistory&gt; &lt;whMonthRecords month="2010-10"&gt; &lt;whDateList month="2010-10"&gt; &lt;date&gt;01&lt;/date&gt; &lt;date&gt;05&lt;/date&gt; &lt;date&gt;21&lt;/date&gt; &lt;/whDateList&gt; &lt;/whMonthRecords&gt; &lt;whMonthRecords month="2010-11"&gt; &lt;whDateList month="2010-11"&gt; &lt;date&gt;01&lt;/date&gt; &lt;date&gt;05&lt;/date&gt; &lt;date&gt;06&lt;/date&gt; &lt;date&gt;07&lt;/date&gt; &lt;date&gt;08&lt;/date&gt; &lt;date&gt;09&lt;/date&gt; &lt;date&gt;12&lt;/date&gt; &lt;date&gt;13&lt;/date&gt; &lt;date&gt;14&lt;/date&gt; &lt;date&gt;16&lt;/date&gt; &lt;date&gt;18&lt;/date&gt; &lt;date&gt;19&lt;/date&gt; &lt;date&gt;21&lt;/date&gt; &lt;date&gt;22&lt;/date&gt; &lt;date&gt;23&lt;/date&gt; &lt;date&gt;24&lt;/date&gt; &lt;date&gt;25&lt;/date&gt; &lt;date&gt;26&lt;/date&gt; &lt;date&gt;29&lt;/date&gt; &lt;/whDateList&gt; &lt;/whMonthRecords&gt; &lt;/watchHistory&gt; &lt;/user&gt; &lt;/users&gt; </code></pre> <p>thank you very much!!</p>
    singulars
    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.
 

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