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

  • Home
  • SEARCH
  • 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 6338889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:32:18+00:00 2026-05-24T19:32:18+00:00

I have written a small jQuery plugin with the following structure: (function($) { //

  • 0

I have written a small jQuery plugin with the following structure:

(function($) {
   // Private vars

   // Default settings
   $.PLUGINNAME = {
         id: 'PLUGINNAME',
         version: '1.0',
         defaults: {
              min: 0,
              max: 10
         }
   };

   // extend jQuery
   $.fn.extend({

       PLUGINNAME: function(_settings) {

           init = function() {

           }

           prepare = function() {

           }

           ...

           return this.each(function() {
                 _this = this;
                 init();
           });

       }

   });

})(jQuery);

I am calling this as follows:

$("#update-panel").PLUGINNAME({
                min: 1,
                max: 20  
          });

I am trying to provide an additional public method where some data inside the function can be updated after the above function call to the plugin and am not sure how to go about doing this. What I am looking for is something like this:

_PluginInstance = $("#update-panel").PLUGINNAME({
                    min: 1,
                    max: 20  
                   });
...
...
_PluginInstance.setMin(2); //should change the minimum to 2

setMin will probably use some of the plugin’s internal variables so I am not understanding how to do this. I know I am not returning an instance of the plugin to do the above but can someone please tell me how to go about doing this by keeping the same plugin structure?

  • 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-24T19:32:19+00:00Added an answer on May 24, 2026 at 7:32 pm

    Just make the function a property of this within the PLUGINNAME object:

    (function($) {
       $.PLUGINNAME = {
         // Default settings
       };
    
       // extend jQuery
       $.fn.extend({
           PLUGINNAME: function(_settings) {
    
               // private methods
               var init = function() {};
               var prepare = function() {};
    
               // public methods
               this.setMin = function ( val ) {
                 _settings.min = val;
               };
               this.getMin = function () {
                 return _settings.min;
               };
    
               return this.each(function() {
                 _this = this;
                 init();
               });
           }
       });
    })(jQuery);
    

    Then you could do:

    _PluginInstance = $("#update-panel").PLUGINNAME({
                        min: 1,
                        max: 20  
                       });
    _PluginInstance.getMin(); // 1
    _PluginInstance.setMin(2);
    _PluginInstance.getMin(); // 2
    

    EDIT: Oh god I can’t believe I forgot the var keywords, why didn’t y’all tell me my fly was down?

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

Sidebar

Related Questions

I've written a small lightbox plugin for jQuery (yes, there are several ready made
I have written a small jquery application that allows a person to slide a
I have written a small unit test for my django view .My project structure
I have written a small java application for which I need to obtain performance
I have written a small Perl script and now I would like to create
As a Christmas gift I have written a small program in Java to calculate
In Ruby I have often written a number of small classes, and had a
I have a small AJAX application, written in PHP that I did not secure
I have written a site in Prototype but want to switch to jQuery. Any
I am having a real headache. I have written a small and simple menu

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.