最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - fullcalendar prevnext click - Stack Overflow

programmeradmin1浏览0评论

i add a javascript to catch user click on prev button (to get that month's data)

$(".fc-prev-button span").click(function(){
                var view = $('#calendar').fullCalendar('getView');
                console.log("The view's title is " + view.intervalStart.format());
                console.log("The view's title is " + view.name);
                return false;
            });

but every time a user click, it will log 3 times, means on click on the button, 3 times call the function, if there is a way to just call 1 time?

or anyone has a better idea to deal with user click on the prev / next button?

i add a javascript to catch user click on prev button (to get that month's data)

$(".fc-prev-button span").click(function(){
                var view = $('#calendar').fullCalendar('getView');
                console.log("The view's title is " + view.intervalStart.format());
                console.log("The view's title is " + view.name);
                return false;
            });

but every time a user click, it will log 3 times, means on click on the button, 3 times call the function, if there is a way to just call 1 time?

or anyone has a better idea to deal with user click on the prev / next button?

Share Improve this question asked Aug 13, 2015 at 11:06 ChanChan 1172 silver badges6 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7

Better use built in events to get your data. You could listen to viewRender and get your data like this:

$("#calendar").fullCalendar({
    viewRender: function(view, element) {
        console.log("The view's title is " + view.intervalStart.format());
        console.log("The view's title is " + view.name);
    }
});

view Render Documentation

Probably this will avoid your problem.

Try to delete span in selector. May be that would help. There are three spans inside of the button...

发布评论

评论列表(0)

  1. 暂无评论