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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:44:11+00:00 2026-06-05T15:44:11+00:00

I have written some relatively simple jQuery plug-ins, but I am contemplating writing something

  • 0

I have written some relatively simple jQuery plug-ins, but I am contemplating writing something more advanced in order to keep commonly used methods on the site easily accessible and DRY

For example, I might have something like this for a structure:

plugin
- popup
- element
...

=== popup ===
- login
- product
...

=== element ===
- shoppingCart
- loginStatus
...

So, to bind a popup login popup event, I’d like to be able to do:
$(‘#login_button’).plugin.popup.login();

What’s the best way to do this? Is there a better way of achieving what I want to do?

Cheers,

  • 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-05T15:44:14+00:00Added an answer on June 5, 2026 at 3:44 pm

    The way farhan Ahmad did it was pretty much right… it just needs deeper levels to suit your needs your implementation would look like this:

    jQuery.fn.plugin = function(){
      //"community" (global to local methods) vars here.
      var selectedObjects = this; //-- save scope so you can use it later
    
      // return the objects so you can call them as necessary
      return {  
                popup: { //plugin.popup
                        login: function(){ //plugin.popup.login
                             //selectedObjects contains the original scope
                             console.log(selectedObjects);
                        },
                        product: function(){} //plugin.popup.product
                },
                element: { //plugin.element
                        shoppingCart: function() {}, //plugin.element.shoppingCart
                        loginStatus: function() {} //plugin.element.loginStatus
                }
             }
    }
    

    So now if you call:
    $("#someDiv").plugin.login(); the result will be as expected. I hope this helps.

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

Sidebar

Related Questions

I have written a relatively big insert statement, and some of the fields are
I have written some jQuery ajax code where I am sending a request to
I have written some code to ensure that items on an order are all
I have written some code to display a YouTube video on my page but
I have written some code which produces simple animations based on cycling through a
I have a relatively simple program written in C++ and I have been using
I want to design a multilevel menu using jQuery. I have already written some
I am relatively proficient in Objective-C but I have been looking around some frameworks
I have written some code for playing a .wav through my application. Now I
I have written some sample program and DLL to learn the concept of DLL

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.