如何使用 GWT 在 Fullcalendar 的 next/prev 按钮上挂钩事件?

How to hook event on next/prev button of Fullcalendar with GWT?

使用https://gwtbootstrap3.github.io/gwtbootstrap3-demo/#fullcalendar

你好

最简单的方法是挂接显示 viewRender 事件。正如 documentation 所述:

This callback will get triggered when the user changes the view, or when any of the date navigation methods are called.

代码如下:

GeneralDisplay generalDisplay = new GeneralDisplay();
generalDisplay.setViewRenderCallback(new ViewRenderCallback() {
    @Override
    public void windowResize(JavaScriptObject view) {
    }

    @Override
    public void viewRender(JavaScriptObject view, Element element) {
        Window.alert("viewRender");
    }

    @Override
    public void viewDestroy(JavaScriptObject view, Element element) {
    }

    @Override
    public void dayRender(JavaScriptObject moment, Element tdElement) {
    }
});

CalendarConfig config = new CalendarConfig();
config.setGeneralDisplay(generalDisplay);

final FullCalendar calendar = new FullCalendar(Document.get().createUniqueId(), ViewOption.month, config, false);

要为特定日期设置背景,只需使用 Background events:

Event backgroundEvent = new Event(Document.get().createUniqueId(), "");
backgroundEvent.setStart(new Date(1511136000000L));
backgroundEvent.setAllDay(true);
backgroundEvent.setRendering("background");
backgroundEvent.setBackgroundColor("red");
calendar.addEvent(backgroundEvent);