开发者

jquery ui datepicker back button jumps to 1899

I must be missing some setting or something, but when I use the back button the datepicker jumps to 1899 from the current year.

Has anyone else seen this and fixed it?

(You can see开发者_如何学编程 the different combos I've commented out.)

    $('.dialog-search,#from')
   .datepicker({
    defaultDate: 'c-1m',
    dateFormat: 'yymmdd',
    //changeMonth: true,
    changeYear: true,
    showAnim: 'fadeIn',
    duration: 200,
    //gotoCurrent: true, 
    showOtherMonths: true,
    selectOtherMonths: true,
    currentText: 'Now',
    shortYearCutoff: '+20',
    //showWeek: true,
    //firstDay: 1,
    numberOfMonths: 1,
    showButtonPanel: true,
    yearRange: 'c-200:c',
    onSelect: function(selectedDate,inst) {
     $('.dialog-search,#from').val(selectedDate);
    }
   });


I had this issue when I had multiple text inputs with the same ID, which is easy to do with MVC frameworks when you have multiple editors on page for same model class. I resolved it by explicitly specifying Id and leaving Name as is, so that model resolving works on postback.


I experienced this issue when calling

$(...).datepicker('destroy')

before re-initializing the datepicker.


It happens when if you have a default instance, because in jQuery plugin its configured that default date is 1899.

We have to just find out why this when this default date code fires


I have created a demo with your code in jsfiddle and I can't reproduce your problem. Can you check it at http://jsfiddle.net/w78xX/.


I have same issue. I'm populating datepicker fields with ajax and showing them on PrettyPhoto as popup.

Here is my code.

$( "body" ).on( "focus", ".tarih", function() {
    //$('.tarih').datepicker('destroy');
    var i = 0;
    $('.tarih').each(function () {
        //$(this).attr("id",'date' + i).datepicker('destroy');
        $(this).attr("id",'date' + i).datepicker({
            dateFormat: "yy-mm-dd",
            firstDay: 1,
            minDate: new Date(2000, 1 - 1, 1)
        });
        i++;
    });
});


Try using: format: 'mm/dd/yyyy hh:ii:ss P' The trick is to keeping your date format the same as what the back-end returns.


I had the same issue and adding the useCurrent: false resolves it.

.datepicker({
        useCurrent: false 

    });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜