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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T23:56:22+00:00 2026-06-18T23:56:22+00:00

I am creating my first jQuery plugin that I would like to use for

  • 0

I am creating my first jQuery plugin that I would like to use for my projects.
However, the knowledge I have is not enough probably. Still, I wanna continue creating it…

So I have this part in my little plugin:

jQuery Plugin – Default Settings:

;(function($) {

var defaults = {

    title               : 'miniBox - Title Spot!',
    description         : 'miniBox Description Spot. Write a short article or leave it blank!',

    buttons: {
        switcher        : true,
        nameButton_1    : 'Continue',
        nameButton_2    : 'Discard',
    }
};

Now below we have this part:

$.fn.miniBox = function(customs) {
    var config = $.extend({}, defaults, customs);
    var $first = this.first();

    $first.init = function() {
        $('body').append( // -->
            '<div class="miniBox-wrap">'
        +       '<div class="miniBox-frame">'
        +           '<div class="miniBox-title"></div>'
        +           '<div class="miniBox-content">'
        +               '<div class="miniBox-description"></div>'
        +               '<div class="miniBox-buttons"></div>'
        +               '<div class="miniBox-counter"></div>'
        +           '</div>'
        +       '</div>'
        +       '<div class="miniBox-overlay"></div>'
        +   '</div>' // <--
        );

        var mB_buttonOne    = config.buttons.nameButton_1,
            mB_buttonTwo    = config.buttons.nameButton_2,
            mB_title        = config.title,
            mB_description  = config.description;

        // --> Confirmation Buttons - Settings OPEN //
        if(config.buttons.switcher === true) {
            $('.miniBox-buttons').append( // -->
                '<input type="button" id="agree" value=' + mB_buttonOne + '>'
            +   '<input type="button" id="disagree" value=' + mB_buttonTwo + '>'
            // <--
            );
        } else {
            $('.miniBox-buttons').remove();
        }
        // <-- Confirmation Buttons - Settings CLOSE //
        };
            $first.init();
    };

})(jQuery);

It is confusing a little bit to me, for the first time I guess…

QUESTION:

The title leads to settings fail so here’s another question.

My settings appears to be working if I set default title and description and then create custom title or/and description … It works, it will override defaults.

However as you can read that short if statement for buttons… It still works and overrides default settings if my buttons switcher is set to false or true in defaults or customs… However if defaults and customs both say: true or false… buttons value becomes “undefined”.

I have no clues how to say always read custom settings only, if they are defined and forget about defaults… Or something like that. I hope you guys understand me and hopefully I’ll find an answer.

Regards, Nenad.

EDIT:

Appears like I need to define completely a button config into customs in order not to get “undefined”… How can I fix this?

Example of Defaults:

var defaults = {
    buttons: {
        switcher        : false,
        nameButton_1    : 'Continue',
        nameButton_2    : 'Discard',
    }
};

Example of Customs:

$(function() {
$().miniBox({
    title: 'Works flawlessly!',
    buttons: {
        switcher: true
    }
});

});

How can I still use defaults buttons settings for button names if they are not defined into custom settings ?

  • 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-18T23:56:23+00:00Added an answer on June 18, 2026 at 11:56 pm

    .first is just a jQuery method. It selects the first element from the collection.

    The init method is a defined function, which is then called immediately (a bit pointless in this case) although you could call it later on outside of the plugin code (also pointless).

    As for the second part of your question, you were not recursively .extending the objects, so the nested object values weren’t getting extended. Use true as the first argument to .extend to make it deep: http://jsfiddle.net/ntdLu/1/

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

Sidebar

Related Questions

I am creating my first jQuery plugin and have a somewhat working example (see
I am creating my first wordpress plugin. one of the questions i have is
I'm creating a small jQuery plugin for my CMS that styles certain form input
I have an unordered list that I would like to wrap inside another unordered
I am creating a form validation in jQuery, but I have some problems; First
this is my first atempt of creating a jquery plugin so I thought id
I'm creating a jquery plugin for sorting and pagination a table (I know that
I'm creating my first application and I have a window consisting of multiple subclasses
I am creating my first (!) database, and I have run into an issue
I am writing a object-oriented jquery plugin. I have a class and I am

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.