简体   繁体   English

jQuery完整日历:“上一个”和“下一个”按钮上的某些单击被忽略

[英]JQuery Full Calendar: some clicks are ignored on Prev and Next buttons

I'm using JQuery Full Calendar. 我正在使用JQuery Full Calendar。 I created two additional listeners for the Prev and Next button, but it seems that, sometimes, I lose some "clicks". 我为“上一个”和“下一个”按钮创建了两个附加的侦听器,但有时似乎会丢失一些“单击”。 Both Prev and Next buttons have two onClick listeners (one is mine and one is the standard listener belongs to the full calendar). Prev和Next按钮都有两个onClick侦听器(一个是我的,一个是标准侦听器,它属于完整日历)。 Is that possible or not? 有可能吗? Sometimes my listener seems to be ignored. 有时我的听众似乎被忽略了。 These are my two simple functions: 这是我的两个简单功能:

$('#calendar').on('click', '.fc-button-prev span', function(){

            console.log("click prev");

        }); 

$('#calendar').on('click', '.fc-button-next span', function(){

            console.log("click next");
        });

Thank you in advance! 先感谢您!

Your click-handlers are attached to a span inside the .fc-button-prev and .fc-button-next . 您的点击处理程序会附加到.fc-button-prev.fc-button-next内部的跨度上。 The JQuery calendar event handlers are attached directly to the .fc-button-prev element (Which also happens to be a span). JQuery日历事件处理程序直接附加到.fc-button-prev元素(也恰好是一个跨度)。 The spans inside the prev and next elements are much smaller in width and as such has a smaller click area. prev和next元素内部的跨度在宽度上要小得多,因此单击区域也较小。

Change your event handlers to: 将事件处理程序更改为:

$('#calendar').on('click', '.fc-button-prev', function(){

        console.log("click prev");

    }); 

$('#calendar').on('click', '.fc-button-next', function(){

        console.log("click next");
    });

And no events should be lost. 而且,任何事件都不应丢失。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM