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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:58:01+00:00 2026-05-21T03:58:01+00:00

I DO NOT WANT TO CREATE A JQUERY PLUGIN Let’s say I have something

  • 0

I DO NOT WANT TO CREATE A JQUERY PLUGIN

Let’s say I have something like this:

// In folib.js
function Foo() {this.Prop = function() {//do something}};

So my users can reference my JavaScript library and instantiate my object all day

// In consumer
foo = new Foo();
alert(foo.Prop);

Now, I want to create a JQuery like plugin system for my class, whereas I can create plugin script libraries which extend Foo().

I think I should be doing something like this…

(function( foo ){
    foo.myPlugin = function() {  
       // Do your awesome plugin stuff here
    };
})(Foo);

But I can’t get that working. Any ideas on how this is done in JQuery? I can’t figure it out 🙁

  • 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-21T03:58:02+00:00Added an answer on May 21, 2026 at 3:58 am

    Using prototype:

    Foo.prototype.myPlugin = function () { /* Do plugin stuff */ };
    

    Then you will be able to access the plugin like so:

    var foo = new Foo();
    alert(foo.myPlugin);
    

    Prototypes work when used in conjunction with new: the new object (foo) has a hidden pointer to the prototype object of the function it was constructed from (Foo). If a property isn’t found on the new object, JS will search for it in the prototype. For more information, read this.

    jQuery does a similar thing by providing a fn property which points to prototype:

    Foo.fn = Foo.prototype;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a jquery plugin, and I want have the following
I want to create NUnit test to ensure that my function does not throw
I want to create a new web-browser for android, but this browser is not
I am trying to create my own styled checkbox jQuery plugin. What I want
hos can create masked Input for date and time by jQuery? i not want
I want to create a property grid like this: Ext JS Property Grid demo
I want to create a plugin that works like so: var fmatted = $('someString').myFunction();
I want to create an intro page, like what is in this site via
I'm using the ajaxform jQuery plugin to create ajaxed HTML forms and want to
I am using this plugin to let users upload images trough ajax. To create

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.