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 6797645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:38:03+00:00 2026-05-26T18:38:03+00:00

Let’s assume that we have following jQuery plugins (each of them in separate files):

  • 0

Let’s assume that we have following jQuery plugins (each of them in separate files):

  • $.fn.foo
  • $.fn.foo.bar
  • $.fn.foo.baz

I use standard jQuery plugin pattern. The first one is actually a proxy or “facade” to the rest plugins of it’s namespace.
For example, when I call $('#el').foo(), under the hood I also call:

var context = this; // context is equal to $('#el')
$(context).foo['bar'].apply(context);
$(context).foo['baz'].apply(context);

There are two problem when I want to call only (without $.fn.foo) $('#el').foo.bar(). The first problem is that there are no $.fn.foo namespace but I can create it, so this is actually no problem. The second problem is that this inside $.fn.foo.bar is equal to document object but I want to be equal to $('#el'). How can I do that?

So, making a long story short, both should work:

$('#el').foo();     // This also calls foo.bar and foo.baz under the hood
$('#el').foo.bar(); // I'm calling foo.bar explicitly
  • 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-05-26T18:38:03+00:00Added an answer on May 26, 2026 at 6:38 pm

    I think you might just need to follow a different plugin pattern. Here is a nice repository of jQuery plugin patterns, but the one you might want to look at would be the namespace pattern – you’ll see how the namespace gets defined initially if it doesn’t already exist, and this allows you to more easily extend from a single namespace across multiple scripts.


    Update: Hmm, I’m still learning so I wouldn’t say I’m an expert at this, but trying to get this $('#el').aaa.bbb.ccc() to work got really messy for me. Maybe it would be better to not use that format, but instead do this (demo):

    $.aaa.bbb.ccc( $("#el") );
    

    because then it is relatively easy to set up:

    (function() {
        if (!$.aaa) {
            $.aaa = {
                bbb : {
                    ccc: function(el, options){
                        alert(el[0].id);
                    }
                }
            };
        };
    })(jQuery);
    
    $(function() {
        $.aaa.bbb.ccc( $("#el") ); // alerts "el"
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say that I have a SQLite database that I create in a separate
Let assume we have two activities. A - main activity, that is home launcher
Let's say I don't have photoshop, but I want to make pattern files (.pat)
Let me explain best with an example. Say you have node class that can
Let's say I have the following object: var VariableName = { firstProperty: 1, secondProperty:
Let's say I have multiple requirements for a password. The first is that the
Let's assume that a user votes for some movies in a scale of 1
Let's say that I have a date in R and it's formatted as follows.
Let say I have the following desire, to simplify the IConvertible's to allow me
Let's say you have a class called Customer, which contains the following fields: UserName

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.