How to Implement minTime and slotDuration dynamic update in FullCalendar

Source: Internet
Author: User

How to Implement minTime and slotDuration dynamic update in FullCalendar

Recently, the jQuery plug-in FullCalendar is used to enable a patient's appointment for a doctor. The general requirements are as follows:

1. The doctor first sets his/her next month's visit time on a weekly basis, including the start time, End Time, And the appointment interval.

2. The patient selects the doctor's appointment time and makes an appointment through the online appointment system.

3. Doctors can view their appointment schedules to learn about patient appointments. The FullCalendar plug-in is used to achieve the following results:

 



Now the problem arises. If the Doctor's commuting time is different for different weeks or months, will the timeline on the left be changed after we jump to another week, unfortunately, FullCalendar does not provide this function unless you call the destroy method and re-initialize the calendar:

$ ('# Mycalendar'). fullCalendar ('deststroy ');

$ ('# Mycalendar'). fullCalendar (calendarOptions );

 

However, the result is that the information of the calendar record will be initialized, that is, the default time will start from the current week, so that you will never be able to jump to the next week.

 

The plug-in itself supports switching between the 'month, agendaWeek, and agendaday' views, and saves no information during view switching, I have hidden the function of switching a view. Can I simulate switching a view, that is, to switch the date jump from the agendaWeek View to the agendaWeek view.

By viewing the FullCalendar source code and referring to comments from netizens, we found that this idea is feasible. By modifying the FullCalendar source code, we can perfectly meet our needs. The record is as follows:

 

1. Simulate the built-in t. changeView = changeView;

Adds a refreshView method,

 

First, add a line:

'T. refreshView = refreshView ;'

 

2.

Implement the refreshView method: Simulate the changeView method call _ changeView (newView), but specify newView as the current view type. Add the following:

Function refreshView ()

{

_ ChangeView (currentView. name );

}

 

3. Pass in the parameter through the option () method, and then call the refreshView method. Modify the option method as follows:

 

Function option (name, value ){

If (value = undefined ){

Returnoptions [name];

}

If (name = 'height' | name = 'contentheight '| name = 'aspectratio '){

Options [name] = value;

UpdateSize ();

}

// ------------- Add by rcm on 2015/1/21 begin ------

If (name = 'slotduration' | name = 'mintime' | name = 'maxtime ')

{

Options [name] = value;

 

RefreshView ();

}

// ------------- Add by rcm on 2015/1/21 end ------

}

OK.

Events: function (start, end, timezone, callback ){

 

It can be called as follows:

$ Calendar. fullCalendar ('option', 'mintime', data. beginBusiness );

$ Calendar. fullCalendar ('option', 'maxtime', data. endBusiness );

$ Calendar. fullCalendar ('option', 'slotduration', data. slotDuration );

 

}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.