jQuery UI Datepicker show current week on load [duplicate]

ⅰ亾dé卋堺 提交于 2019-12-25 15:15:21

问题


After implementing datepicker, I am able to show Week picker using this. But in addition to this I even want to show the current week range on load.

When user clicks on any date, it shows the week range but how can I show current week range onload as well ?

For example, if user clicks on Nov 2 it shows the week range Nov 2 - Nov 8 but not showing the current week range which is Oct 26 - Nov 1 by default onload.

The below function shows the current week start and end date, but how can I show it on load without onselect.

var showCurrentWeek = function() {

        var defaultStartDate = $('#startDate').text($.datepicker.formatDate( 'M d', startDate));
        var defaultEndDate = $('#endDate').text($.datepicker.formatDate( 'M d', endDate));
        alert(defaultStartDate.text());
        alert(defaultEndDate.text());
    }

How can I achieve this ?

Thanks.


回答1:


There are probably other ways to do this, but here's one. Simulate a click on the current date by adding this code:

$(function() {

    ......

    $(".ui-datepicker-current-day").click();
}


来源:https://stackoverflow.com/questions/26686307/jquery-ui-datepicker-show-current-week-on-load

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