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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:59:21+00:00 2026-06-18T04:59:21+00:00

I am working on creating a dialog plugin using JQuery Dialog . Below are

  • 0

I am working on creating a dialog plugin using JQuery Dialog . Below are the parameters which can be passed . It includes button text which user wants to add and call back function name which would be executed on click of that button .

    var settings = $.extend({
        message: 'Your action is successful',
        title: 'Message',
        showButton: true,
        buttonText: 'OK',
        onButtonClick: 'OnButtonClick',
        allowClose: true
    }, options);

I am facing issues to attach that function name to click event of the button . I am trying to do something like below but it throws error .

    $('#dialog-message').dialog({
        buttons: [{
            text: settings.buttonText,
            click: window[settings.onButtonClick]()

        }],
        closeOnEscape: true,
        close: function (e) {
            $(this).empty();
            $(this).dialog('destroy');
    }
    });

Any suggestions How can I attach that Function Name to click event as I only have the function name .

  • 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-18T04:59:22+00:00Added an answer on June 18, 2026 at 4:59 am

    The callers of your plugin should provide a callback for the onButtonClick option rather than a string. Like so:

    function OnButtonClick(){
       //does some cool stuff
    }
    
    var settings = $.extend({
        message: 'Your action is successful',
        title: 'Message',
        showButton: true,
        buttonText: 'OK',
        onButtonClick: OnButtonClick,
        allowClose: true
    }, options);
    

    And then you could bind the incoming function like this:

    $('#dialog-message').dialog({
        buttons: [{
            text: settings.buttonText,
            click: settings.onButtonClick
        }],
        closeOnEscape: true,
        close: function (e) {
            $(this).empty();
            $(this).dialog('destroy');
        }
    });
    

    This is possible because the onButtonClick variable now holds a reference to the callback that the user of your plugin provided (as opposed to a string) through the settings they used to initialize the plugin.

    Hope that helps!

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

Sidebar

Related Questions

Background I have been using the JQuery UI plugin for creating a dialog that
I am creating a dialog using MVVM which prompts the user to type in
I am creating my first jQuery plugin and have a somewhat working example (see
I'm working on creating a custom dialog to get input from the user. I've
I've been working on creating a Spell check dialog for the tinyMCE editor using
I'm creating a dialog box and using the (this) isnt working. Up until now
I'm using M-V-VM with dialog boxes. The process I'm using for creating dialogs is
working on creating an XML file with some data using Python. I am trying
i am working on creating a coupon for ipassbook using passsource.com, does anybody know
I am working on creating a website in Django which consists of two parts:

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.