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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:59:15+00:00 2026-05-11T06:59:15+00:00

I’m looking to create a generic confirmation box that can be used by multiple

  • 0

I’m looking to create a generic confirmation box that can be used by multiple widgets easily, but I’m running into problems with scope and was hoping for a clearer way of doing what I’m trying to do.

Currently I have the following –

(function() {      var global = this;     global.confirmationBox = function() {     config = {         container: '<div>',         message:''     }     return {         config: config,         render: function(caller) {             var jqContainer = $(config.container);             jqContainer.append(config.message);             jqContainer.dialog({                 buttons: {                     'Confirm': caller.confirm_action,                      Cancel: caller.cancel_action                 }             });         }     } } //end confirmationBox global.testWidget = function() {     return {         create_message: function(msg) {             var msg = confirmationBox();             msg.message = msg;             msg.render(this);         },         confirm_action: function() {             //Do approved actions here and close the confirmation box             //Currently not sure how to get the confirmation box at             //this point         },         cancel_action: function() {             //Close the confirmation box and register that action was              //cancelled with the widget. Like above, not sure how to get             //the confirmation box  back to close it         }     } }//end testWidget })(); //Create the widget and pop up a test message var widget = testWidget(); widget.create_message('You need to confirm this action to continue'); 

Currently I’m just looking to do something as simple as close the box from the within the widget, but I think I’ve wrapped my own brain in circles in terms of what knows what. Anyone want to help clear my befuddled brain?

Cheers, Sam

The resulting code:

I thought it might be useful for people who find this thread in later days looking for a solution to a similar problem to see the code that resulted from the helpful answers I got here.

As it turns out it was pretty simple in the end (as most of the frustrating mind-tangles are).

 /**  * Confirmation boxes are used to confirm a request by a user such as  * wanting to delete an item  */  global.confirmationBox = function() {     self = this;     config = {         container: '<div>',         message: '',      }     return {         set_config:config,         render_message: function(caller) {             var jqContainer = $(config.container);             jqContainer.attr('id', 'confirmation-dialog');             jqContainer.append(config.message);             jqContainer.dialog({                buttons: {                    'Confirm': function() {                        caller.confirm_action(this);                     },                    Cancel: function() {                        caller.cancel_action(this);                    }                }            });         }     }  } // end confirmationBox   global.testWidget = function() {     return {         create_message: function(msg) {             var msg = confirmationBox();             msg.message = msg;             msg.render(this);         },         confirm_action: function(box) {             alert('Success');             $(box).dialog('close');          },         cancel_action: function(box) {             alert('Cancelled');             $(box).dialog('close');          }     } }//end testWidget 
  • 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. 2026-05-11T06:59:15+00:00Added an answer on May 11, 2026 at 6:59 am

    You could pass jqContainer to the confirm/cancel functions.

    Alternately, assign jqContainer as a property of caller. Since the confirm/cancel functions are called as methods of caller, they will have access to it via this. But that limits you to tracking one dialog per widget.

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

Sidebar

Ask A Question

Stats

  • Questions 118k
  • Answers 118k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can use google-api-translate-python to talk to google api. EDIT:… May 11, 2026 at 11:39 pm
  • Editorial Team
    Editorial Team added an answer Here's my explanation at why this is a better practice:… May 11, 2026 at 11:39 pm
  • Editorial Team
    Editorial Team added an answer If you want to do something like that, I think… May 11, 2026 at 11:39 pm

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.