Geeks With Blogs
Ben Adler's Development Posting solutions as I find them

I'm using the fullcalendar from: arshaw.com/fullcalendar/ version 1.5.1

I'm only using the month view and wanted to disable the previous buttons so that the user could not view months in the past.

Inside the renderView(inc) function in the FullCalendar.js file, I added this on line 408:


  //This disables the previous buttons so that the user cannot view previous months/years 

                if (today.getMonth() >= parseDate(currentView.start).getMonth() && today.getFullYear() >= parseDate(currentView.start).getFullYear())

                {

                    header.disableButton('prev');

                    header.disableButton('prevYear');

                }

                else if (parseDate(currentView.start).getFullYear() <= today.getFullYear())

                {

                    header.enableButton('prev');

                    header.disableButton('prevYear');

                }

                else if(parseDate(currentView.start).getFullYear() > today.getFullYear() &&  parseDate(currentView.start).getMonth() >= today.getMonth())

                {

                    header.enableButton('prev');

                    header.enableButton('prevYear');

                }

Posted on Friday, May 27, 2011 2:50 PM jQuery | Back to top


Comments on this post: jquery fullcalendar disable prev previous button

# re: jquery fullcalendar disable prev previous button
Requesting Gravatar...
Hi,

Thanks for the solution - works great even with newer version(1.5.2). You've made my day :)

Kind Regards
Kamil Skowron
Left by Kamil Skowron on Nov 07, 2011 5:50 AM

# re: jquery fullcalendar disable prev previous button
Requesting Gravatar...
Thanks, I'm using this in v1.5.4 successfully. It's too bad the plugin doesn't provide this functionality natively without having to modify the code.
Left by Jamie on Feb 11, 2013 5:44 PM

# re: jquery fullcalendar disable prev previous button
Requesting Gravatar...
Couldn't you just have used:
header : {
left : 'prev,next',
center: 'title',
right : 'today'
},
and leave out the "prev" wherever you added the buttons??
Left by Ramie on Jan 28, 2014 8:48 AM

# re: jquery fullcalendar disable prev previous button
Requesting Gravatar...
Thanks for the comment Ramie. I still wanted the previous button, but only wanted it enabled when the month was in the future. If I misunderstood you, perhaps you could post the full code?
Left by Ben Adler on Jan 28, 2014 9:21 AM

Your comment:
 (will show your gravatar)


Copyright © BenAdler | Powered by: GeeksWithBlogs.net