as i have just started developing plugins in jquery i am curious to know the difference between plugin based on name and plugin based on function and what is better approach to develop a plugin
Asked
Active
Viewed 58 times
3
-
Can you explain in more detail? – elclanrs Apr 28 '12 at 11:13
-
@elclanrs i am studying jquery plugin development in which author has explained above 2 ways of developing plugins but nothing written about the difference between two approaches and which to prefer – Bipin Chandra Tripathi Apr 28 '12 at 11:15
-
@Bipin can you link to the article, or give examples of both? – Jonathan Payne Apr 28 '12 at 11:17
-
Do you mean var myfunc = function() vs function myfunc() ? – mddw Apr 28 '12 at 11:19
-
1Well, excellent answerS here : http://stackoverflow.com/questions/336859/javascript-var-functionname-function-vs-function-functionname – mddw Apr 28 '12 at 11:24
1 Answers
1
plugin based on name also called method plugin and plugin based on function also called function plugin
- Method plugins should always return the jQuery object (this, in the code), to allow for chainability.
- Function plugins do not support chainability, Method plugins do support chainability.
- Method plugins should always return the jQuery object (this, in the code), to allow for chainability.
- Method plugins extend the jQuery.fn object, Function plugins directly extends the jQuery object.

VasudhaivaKutumbakam
- 168
- 1
- 9