簡體   English   中英

如何禁用UI日歷中的以前的日期?

[英]How to disable previous dates in Ui calendar?

我是Ui日歷的新手。 我只是想知道如何使用angularjs在Ui日歷中禁用以前的日期。 Eventdrop,EventResize和eventclick對我來說一切正常,我想禁用以前的日期,這樣日歷中的事件就無法刪除或調整為以前的日期! 提前致謝。

要設置事件可以拖放的時間段,請設置eventConstraint屬性:

eventConstraint: {
  start: moment(),
  end: moment().add(100, 'years')
}

參見https://fullcalendar.io/docs/event_ui/eventConstraint/

但是,這僅涵蓋現有事件的拖放。 這對您來說足夠了,但是如果您還需要限制用戶可以拖動以創建事件的位置,則需要以完全相同的方式指定selectConstraint選項:

selectConstraint: {
  start: moment(),
  end: moment().add(100, 'years')
}

https://fullcalendar.io/docs/selection/selectConstraint/

請注意,將moment()設置為開始將限制拖動到字面上的當前時間點(當日歷呈現到瀏覽器時)。 如果您想更加自由一些,並且在當天允許任何事情,可以將其設置為:

start: moment().startOf('day')

或者將日期限制為從明天開始:

start: moment().startOf('day').add(1, "days")

有關更多可能性,請參見http://momentjs.com/docs/#/manipulating/

通過在行代碼ui.calendar config下面添加此代碼,可以防止事件降到以前的日期

eventConstraint: {
        start: moment().format('YYYY-MM-DD'),
        end: '2100-01-01' // hard coded goodness unfortunately
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM