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

The Archive Base Latest Questions

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

http://docs.jquery.com/Plugins/Authoring#Defaults_and_Options describes how a plugin could have default options. var settings = $.extend( {

  • 0

http://docs.jquery.com/Plugins/Authoring#Defaults_and_Options describes how a plugin could have default options.

var settings = $.extend( {
  'location'         : 'top',
  'background-color' : 'blue'
}, options);

The second part of the selected answer jQuery Plugin: Adding Callback functionality describes how to add a callback in the option object.

// extend the options from pre-defined values:
var options = $.extend({
    callback: function() {}
}, arguments[0] || {});

// call the callback and apply the scope:
options.callback.call(this);

How would I add both default settings and a callback function at the same time? Also, I am a little confused on why I would extend the default callback function against arguments[0] or an empty object. Thanks

  • 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-13T16:39:07+00:00Added an answer on June 13, 2026 at 4:39 pm

    simply merge both, you can have as many items in a object as you want

    $.fn.myPlugib = function( user_options ) {  
        var options = $.extend({
            'location'         : 'top',
            'background-color' : 'blue'
            'callback': function() {}
        }, user_options || {});
    
        //now options object can be used to get callback or any other options when needed
        options.callback.call(this, options.location)
    }
    

    user_options || {} makes sure that if user hasn’t provided any options we use empty options object

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

Sidebar

Related Questions

I defined my plugin base on http://docs.jquery.com/Plugins/Authoring (function( $ ){ var methods = {
I was looking at http://docs.jquery.com/Plugins/Authoring#Defaults_and_Options to create a simple plugin for jQuery. Following the
All, I am trying to use JQuery's URL Validator plugin. http://docs.jquery.com/Plugins/Validation/Methods/url I have a
The official documentation http://docs.jquery.com/Plugins/Authoring#Namespacing states that methods should be added to a jQuery plugin
Using the jQuery plugin found here: http://docs.jquery.com/Plugins/Validation I have a form, that when certain
jQuery Validation plugin is used to validate all form data: http://docs.jquery.com/Plugins/Validation Have 3 select
Im using jQuery validation plugin http://docs.jquery.com/Plugins/validation to do some client side validations. I have
I'm looking at the Plugin Authoring article at http://docs.jquery.com/Plugins/Authoring and saw this example in
I'm following the tutorial here: http://docs.jquery.com/Plugins/Authoring I just wanted to create a simple plugin
I'm using the JQuery tooltip plugin - http://docs.jquery.com/Plugins/Tooltip With the basic implementation: $(.tooltip).tooltip(); Instead

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.