切换设置filterResourcesWithEvents自定义按钮忽略jQuery的文本()调用

问题描述 投票:0回答:1

我想添加自定义按钮来切换选项filterResourcesWithEvents。理想情况下,按钮会改变风格融入了压状态,但现在我只是想设置选项后更改按钮上的文字。问题是,该文本不会更改。

人们可以在这里CodePen找到一个完整的例子。

custom1: {
 text: 'Filter off',
 click: function() {
        var cal = $('#calendar').fullCalendar('getCalendar');
        var newFilterResourcesWithEvents = ! cal.option('filterResourcesWithEvents');
        cal.option('filterResourcesWithEvents', newFilterResourcesWithEvents);
        // The following line being ignored.
        $(this).text(newFilterResourcesWithEvents ? 'Filter on' : 'Filter off');
}},

我怀疑调度选项功能可能与文本()更新中的干扰。

有没有人有什么建议?

fullcalendar fullcalendar-scheduler
1个回答
1
投票

一个小实验后,我发现,如果我使用一个类选择去改变它只是作品的按钮。我不知道是什么原因。

基本上,如果我取代过去的路线为:

$("button.fc-custom1-button").text(newFilterResourcesWithEvents ? 'Filter on' : 'Filter off');

我希望类的命名保持一致。

© www.soinside.com 2019 - 2024. All rights reserved.