![](/img/trans.png)
[英]Disable national holidays present in my database using jquery pickadate plugin
[英]pickadate does not show a disable days in my ror application
我在rails應用程序中的Pickadate組件有問題。 我無法禁用日歷中的天數。
我在此功能的模型中加載禁用日期:
def busy_days
days = []
reservations.each do |reservation|
reservation_start = ( reservation.reservation_start_date - 1.month)
reservation_end = ( reservation.reservation_end_date - 1.month)
days << "{ from: [#{reservation_start.strftime("%Y,%-m,%d")}], to: [#{reservation_end.strftime("%Y,%-m,%d")}]}"
end
days.join(",")
end
該功能的結果:
{ from: [2018,3,13], to: [2018,3,14]},{ from: [2018,3,12], to: [2018,3,13]},{ from: [2018,3,07], to: [2018,3,10]}
和我的JavaScript看起來像這樣:
- if @subject.reservations.present?
%script
var datesToDisable = ["#{@subject.busy_days}"]
$(document).ready(function() {
$('.datepicker').pickadate({
formatSubmit: 'yyyy/mm/dd',
hiddenSuffix: '',
disable: datesToDisable ,
min: Date.now()
})
});
- else
%script
$(document).ready(function() {
$('.datepicker').pickadate({
formatSubmit: 'yyyy/mm/dd',
hiddenSuffix: ''
})
});
有什么建議么 ?
我正在更新我的busy_days函數,現在可以使用
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.