2009-08-21 13 views

risposta

46

prova l'opzione FirstDay (nella scheda opzioni):

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

Ecco un esempio di configurazione che uso. Guarda l'ultima riga con "firstDay: 1". Penso usando sytax come questo per specificare le opzioni DatePicker sembra migliore;)

$('#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 
}) 
7

per l'utilizzo come primo giorno lunedi:

$(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 
Problemi correlati