Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8737531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:32:39+00:00 2026-06-13T10:32:39+00:00

The official documentation http://docs.jquery.com/Plugins/Authoring#Namespacing states that methods should be added to a jQuery plugin

  • 0

The “official” documentation http://docs.jquery.com/Plugins/Authoring#Namespacing states that methods should be added to a jQuery plugin as shown below. I haven’t seen this design pattern implemented often. It seems like if other plugins use var method, there might be conflicts. Is this really the preferred method, or should I be doing it differently?

(function( $ ){

 var methods = {
  method1: function( options ) {},
  method2: function( ) {}
 };

 $.fn.tooltip = function( method ) {
  if ( methods[method] ) {
   return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
  } else if ( typeof method === 'object' || ! method ) {
   return methods.init.apply( this, arguments );
  }
 };

})( jQuery );
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:32:40+00:00Added an answer on June 13, 2026 at 10:32 am

    If you want to make the methods publically accssible then yes, it is the preferred method. The other option that is possible and sometimes advisable if the plugin is extremely complex is to actually create a full constructed object instead of just using a methods hash. I dont know that that really needs to be done anymore because you can manage state usin .data() on the root element of each instance but its a pattern ive seen and also appreciated before.

    <rant>Additionally, I have had aggravation of late with a lot of plugins… please if you are going to open source it make sure you at least include a destroy method to unbind everything you have done.</rant>

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After running into the Yii asset engine I've read the official documentation (http://www.yiiframework.com/wiki/148/understanding-assets/). I
I'm using the official documentation: http://docs.basex.org/wiki/Commands#String_Syntax , and I haven't been able to locate
For creating PDF documents in iOS, in the official documentation ( http://developer.apple.com/library/ios/#documentation/2DDrawing/Conceptual/DrawingPrintingiOS/GeneratingPDF/GeneratingPDF.html#//apple_ref/doc/uid/TP40010156-CH10-SW3 ), the
In articles like this: http://aaronparecki.com/How_to_Distribute_your_iOS_Apps_Over_the_Air as well as the official Apple Documentation: http://developer.apple.com/library/ios/#featuredarticles/FA_Wireless_Enterprise_App_Distribution/Introduction/Introduction.html it
Official appengine documentation says that if we set threadsafe property to true in app.yaml
My client would like to integrate a flip book plugin - http://www.turnjs.com/ - in
Here's a fiddle with a working Bootstrap carousel. http://jsfiddle.net/jeykeu/5TDff/ And here's the official documentation
From the official documentation: The reuse identifier is associated with a UITableViewCell object that
I read in Sun official documentation (or Sun online tutorial) about dotted naming for
Is there official documentation on the Python website somewhere, on how to install and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.