2012-04-21 31 views
7

Tôi muốn có datepicker được bản địa hóa của mình không cho phép các ngày nhất định được chọn.Kết hợp các tham số địa phương hóa và khởi tạo của jQuery-ui datepick

Localization:

$("#datepicker").datepicker($.datepicker.regional["fr"]); 

Không cuối tuần:

$("#datepicker").datepicker({ beforeShowDay: $.datepicker.noWeekends }) 

tôi không thể tìm ra cách để kết hợp cả hai?

+0

Fix dòng đầu tiên của bạn – neoascetic

+0

@neoascetic, cảm ơn, làm typo khi dán ở đây. Vẫn không chắc chắn làm thế nào để giải quyết. – mishap

Trả lời

13

$.datepicker.regional thuộc tính thuộc tính chứa một loạt các bản địa hóa; bản thân chúng là "cài đặt trước" của datepicker options. Để thêm lựa chọn của bạn (ghi đè nếu cần):

// use $.extend to merge preset options plus your options 
$("#datepicker1") 
    .datepicker($.extend({}, $.datepicker.regional.fr, { 
     beforeShowDay: $.datepicker.noWeekends 
    })); 

// initialize the datepicker, then use .datepicker("option", options) method twice 
$("#datepicker2") 
    .datepicker() 
    .datepicker("option", $.datepicker.regional.fr) 
    .datepicker("option", "beforeShowDay", $.datepicker.noWeekends); 

Demo (see example 5)

Các vấn đề liên quan