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

Related Questions

I have a French site that I want to parse, but am running into
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I'm trying to create an if statement in PHP that prevents a single post
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has

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.