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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:51:26+00:00 2026-06-08T08:51:26+00:00

I am new to jQuery and especially to JavaScript. I am trying to create

  • 0

I am new to jQuery and especially to JavaScript.

I am trying to create a jQuery plugin but have some difficulties with callback events. I want to include callback events into different functions, so that the plugin will be a little bit flexible.

Here is the code:

    (function($, undefined){

    var methods = {

        init: function(options){

            var settings = $.extend({

                // Default settings
                'fadeInOutSpeed'            : 100,
                // the rest of default settings ...

                // Callback events
                onOpenBefore        : function(){},
                onOpen              : function(){},
                onOpenedCloseBefore : function(){}
                // the rest of the callback events...

            }, options);

            // code goes here...

            return this.each(function(){

                // code goes here

            });

        },
        destroy: function(){
            // code goes here
        },
        open: function(){
            console.info('method open accessed');
        },
        close: function(){
            console.info('method close accessed');
        },
        update: function(){
            console.info('method update accessed');
        }

    };

    function gui_selectbox_open(param, event){

        // HOW TO PUT A CORRECT CALLBACK CODE HERE ?
        settings.onOpenBefore.call(param, event);

        // function code goes here

        settings.onOpenAfter.call(param, event);
    };

Inside the function gui_selectbox_open(param,event), there is a line at the beginning, where I want to put a callback event, so I could access it properly when initializing a plugin from outside, which gives me an JavaScript error, telling that settings.onOpenBefore... is not defined. How to define it?

Thanks in advance

  • 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-08T08:51:28+00:00Added an answer on June 8, 2026 at 8:51 am

    Your variable settings is defined as local to the init() function inside your methods object. to make it accessible outside, you can define it outside the init function and access it as methods.settings.yourMethod(..)

    i.e.

    var methods = {
    
        settings: null,
    
        init: function(options){
    
        ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying to use the new jquery-ui, and all but the resizable function
I am new to programming especially jQuery. I am trying to sort (order) images
I am new to programming especially jQuery. I am trying to use ColorBox to
I am new to programming especially jQuery and webservices. I want to pass the
I'm currently new into client-side programming, especially using the Jquery Ajax method to call
When writing a new jQuery plugin is there a straightforward way of checking that
I have application that brings response via Ajax and creates 5-20 new jQuery click
Example: var $doesNotYetExistInTheDOM = $('<span/>'); // create new jQuery element // outside of the
im new to jquery and javascript.. Here is the code, this is a sample,
Very new to JQuery and MVC and webdevelopment over all. I'm now trying to

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.