in jquery ui datepicker, on the OnSelect() event is there anyway to get the previous selected date

…衆ロ難τιáo~ 提交于 2019-12-04 05:26:17

You can use data to store previously stored value and compare the current value to it.

Try this(put these statements in your document ready event):

$('#Milestone').data("prev", $(this).val());
$('#Milestone').datepicker({
    dateFormat: 'dd M yy',
    onSelect: function(dateText){
            var prevDate = $(this).data("prev")
            var curDate = dateText;
            if(prevDate == curDate){
              $(this).data("prev", curDate)
                calcUpdate();
            }
        }
});

According to http://api.jqueryui.com/datepicker/#option-onSelect, you should try this:

$('#Milestone').datepicker({
    dateFormat: 'dd M yy',
    onSelect: function(curDate, instance){
        if( curDate != instance.lastVal ){
            //so, the date is changed;
            //Do your works here...
        }
    }
});

The onSelect function receives 2 parameters which are used here; You can debug/console the values of the 2nd parameter to know more about it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!