2009-08-21 73 views

Trả lời

46

Hãy thử tùy chọn firstDay (trong tab tùy chọn):

//getter 
var firstDay = $('.selector').datepicker('option', 'firstDay'); 
//setter 
$('.selector').datepicker('option', 'firstDay', 1); 
69

Dưới đây là một ví dụ cấu hình tôi sử dụng. Nhìn vào dòng cuối cùng với "firstDay: 1". Tôi nghĩ rằng sử dụng sytax như thế này để xác định datepicker tùy chọn trông tốt hơn;)

$('#datepickerfield').datepicker({ 
    constrainInput: true, // prevent letters in the input field 
    minDate: new Date(), // prevent selection of date older than today 
    showOn: 'button',  // Show a button next to the text-field 
    autoSize: true,   // automatically resize the input field 
    altFormat: 'yy-mm-dd', // Date Format used 
    beforeShowDay: $.datepicker.noWeekends,  // Disable selection of weekends 
    firstDay: 1 // Start with Monday 
}) 
1

Bạn cũng có thể đạt được điều này bằng cách tạo ra tập tin bản địa hóa của riêng bạn cho ngôn ngữ của bạn cùng với các thiết lập của riêng bạn. Xem trang này để biết chi tiết: http://docs.jquery.com/UI/Datepicker/Localization

7

cho việc sử dụng ngày đầu tiên như thứ hai:

$(function() { 
    $("#date_id").datepicker({ firstDay: 1 }); 
}); 
-2
function getFirstDateOfThisWeek(d) 
    { 
     var TempDate = new Date(d || new Date());    
     TempDate.setDate(TempDate.getDate() + (@Config.WeekStartOn - 1 - TempDate.getDay() - 7) % 7);   
     return TempDate; 

    } 

    var StartDate = getFirstDateOfThisWeek(new Date()); //1st date of this week 
Các vấn đề liên quan