我想添加自定义按钮来切换选项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');
}},
我怀疑调度选项功能可能与文本()更新中的干扰。
有没有人有什么建议?
一个小实验后,我发现,如果我使用一个类选择去改变它只是作品的按钮。我不知道是什么原因。
基本上,如果我取代过去的路线为:
$("button.fc-custom1-button").text(newFilterResourcesWithEvents ? 'Filter on' : 'Filter off');
我希望类的命名保持一致。