admin管理员组

文章数量:1323335

I am getting error with jquery version:

<script src="js/Common/jquery-2.1.1.min.js" type="text/javascript"></script>
 <script src=".12.0/jquery-ui.js"></script>

My code is :

var storedData = '["08/11/2016","07/31/2016"]';

        if( storedData !== null){
       var eventDatesarray = JSON.parse(storedData);
        var eventDates = [];

        $.each(eventDatesarray, function( index, value ) {
        var newdatepush = new Date(value);
        eventDates.push(newdatepush);
        eventDates[newdatepush] = newdatepush;
        });
        // An array of dates

        // datepicker
        jQuery('#ScheduleNextVisitCal').datepicker({
            beforeShowDay: function( date ) {
                var highlight = eventDates[date];
                if(highlight) {
                     return [true, "event", highlight];
                } else {
                     return [true, '', ''];
                }
             }
        });

}
else 
{
  $( function() {
    $("#ScheduleNextVisitCal" ).datepicker();
    });

      }

Problem statement :

i want to highlight specific date which i will get in "storedData" via jquery datepicker.

Surprise factor : //ajax.googleapis/ajax/libs/jquery/1.7.0/jquery.min.js //ajax.googleapis/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js

if i am using these libs then my code work fine but somehow i can not change the libs

Error name : daySettings[2].replace is not a function

issue code :

same code with different libs working fine :

I am getting error with jquery version:

<script src="js/Common/jquery-2.1.1.min.js" type="text/javascript"></script>
 <script src="https://code.jquery./ui/1.12.0/jquery-ui.js"></script>

My code is :

var storedData = '["08/11/2016","07/31/2016"]';

        if( storedData !== null){
       var eventDatesarray = JSON.parse(storedData);
        var eventDates = [];

        $.each(eventDatesarray, function( index, value ) {
        var newdatepush = new Date(value);
        eventDates.push(newdatepush);
        eventDates[newdatepush] = newdatepush;
        });
        // An array of dates

        // datepicker
        jQuery('#ScheduleNextVisitCal').datepicker({
            beforeShowDay: function( date ) {
                var highlight = eventDates[date];
                if(highlight) {
                     return [true, "event", highlight];
                } else {
                     return [true, '', ''];
                }
             }
        });

}
else 
{
  $( function() {
    $("#ScheduleNextVisitCal" ).datepicker();
    });

      }

Problem statement :

i want to highlight specific date which i will get in "storedData" via jquery datepicker.

Surprise factor : //ajax.googleapis./ajax/libs/jquery/1.7.0/jquery.min.js //ajax.googleapis./ajax/libs/jqueryui/1.8.16/jquery-ui.min.js

if i am using these libs then my code work fine but somehow i can not change the libs

Error name : daySettings[2].replace is not a function

issue code : http://codepen.io/srawal/pen/KrBkVG

same code with different libs working fine : http://codepen.io/srawal/pen/grjoAx

Share Improve this question edited Jul 30, 2016 at 14:02 supersaiyan asked Jul 30, 2016 at 13:47 supersaiyansupersaiyan 1,7306 gold badges16 silver badges37 bronze badges 2
  • What is daySettings & where is in your code ? – Abdennour TOUMI Commented Jul 30, 2016 at 13:52
  • this issue with liberay : code here : codepen.io/srawal/pen/KrBkVG open the console > change month by arrow to september > daySettings[2].replace is not a function in console of browser – supersaiyan Commented Jul 30, 2016 at 13:59
Add a ment  | 

1 Answer 1

Reset to default 12

eventDates[ new Date( '09/04/2016' )] = new Date( '09/04/2016' ).toString(); eventDates[ new Date( '09/06/2016' )] = new Date( '09/06/2016' ).toString(); eventDates[ new Date( '09/20/2016' )] = new Date( '09/20/2016' ).toString(); eventDates[ new Date( '09/25/2016' )] = new Date( '09/25/2016' ).toString();

This works. Don't pass date into the array. It expects a string. Convert the date into string before putting it in the array. It works.

本文标签: javascriptdaySettings2replace is not a function jquery date pickerStack Overflow