Pergunta

I'm using 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). 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!

Foi útil?

Solução

Your click-handlers are attached to a span inside the .fc-button-prev and .fc-button-next. The JQuery calendar event handlers are attached directly to the .fc-button-prev element (Which also happens to be a span). The spans inside the prev and next elements are much smaller in width and as such has a smaller click area.

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top