1

I'm using fullcalendar, it's really a good tool to create calendar-based application.

But I have a question about the wonderful tool.

When call one method in fullcalendar, we do things like this:

$('#calendar').fullCalendar('next');

I'm wondering why it is not something like this:

$('#calendar').fullCalendar.next();

or even

$('#calendar').next();

that's the way how javascript call a method or function, right?

what's the design philosophy or the necessity behind this?

Thanks! and I'm sorry for my poor English.

尤川豪
  • 459
  • 5
  • 26

1 Answers1

1

The first example makes some sense however I think would probably break chaining or have you return the selected element within the .next() method which may or may not be apllicable, also as .next() is already a jQuery method it would IMO be a bad api decision. jQuery also afaik recomend that you pass a string argument to access otherwise private functions.

The second example .next() would be a method of the jQuery object created be selecting an element with the ID of calender (which it is) and does not make sense in this context

You may wish to look at this question regarding public functions for jQuery plugins and also read this article about plugin design

Community
  • 1
  • 1
T I
  • 9,785
  • 4
  • 29
  • 51