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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:56:22+00:00 2026-05-26T08:56:22+00:00

I am developing the MooTools confirm box function. In which I have two buttons

  • 0

I am developing the MooTools confirm box function. In which I have two buttons which are OK and CANCEL.

So I want return TRUE on click of OK and return FALSE on click on CANCEL.

Here is my function code.

function confirm_box(title, text)
{
    var className = 'msgAlert info';
    var defaut_title ='Information';

    // Placing the Overlay
    var overlay = new Element('div', {'class':'msgAlert_overlay'});
    $$('body').adopt(overlay);

    // Placing the Main Div With class name
    var main_box  = new Element('div', {'class': className});
    $$('body').adopt(main_box);

    var content_div = new Element('div', {'class':'msgAlert_popup'});
    //<a href="javascript:;" class="msgAlert_close"></a>
    if(title == '')
        title=defaut_title;
    content_div.set('html','<div class="msgAlert_header"><h4>'+title+'</h4></div><div class="msgAlert_content">'+text+'</div>');
    main_box.adopt(content_div);

    content_div.getChildren('a.msgAlert_close');

    var footer_div = new Element('div',{'class':'msgAlert_footer'});
    var ok_btn = new Element('button');
    ok_btn.addEvent('click', function(){
        main_box.fade(0);
        //overlay.fade(0);
        (function(){main_box.dispose(); overlay.dispose(); }).delay(350);
        return true;
    });

    var cancel_btn = new Element('button');
    cancel_btn.addEvent('click', function(){
        main_box.fade(0);
        //overlay.fade(0);
        (function(){main_box.dispose(); overlay.dispose();}).delay(350);
        return false;
    });

    ok_btn.set('html','Ok');
    cancel_btn.set('html','Cancel');
    footer_div.adopt(ok_btn);
    footer_div.adopt(cancel_btn);
    main_box.adopt(footer_div);
    ok_btn.focus();
}

I have placed return TRUE and FALSE on click on respective buttons.

Can any suggest in which way I have to go so I can access my function just like the JS confirm box:

Just Like :

if(confirm_box(title, text))
{
 alert('Yes');
}
else
{
 alert('No');
}
  • 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-05-26T08:56:23+00:00Added an answer on May 26, 2026 at 8:56 am

    this is not going to work. basically, you can use the native

    if (confirm("are you sure")) { ... } else { ... }

    which is fine, because it is blocking the UI thread…

    when you want to replicate a confirm box, you need to work with an event callback method instead as your function will NOT have a return value.

    in pseudo code, this will be:

    var confirm_box = function(title, text, onConfim, onCancel) {
    
        ... 
        confirmEl.addEvent("click", onConfirm);
    
        cancelEl.addEvent("click", onCancel);
    };
    
    
    confirm_box("Are you sure?", "Please confirm by clicking below", function() {
        alert("yes");
    }, function() {
        alert("no");
    });
    

    in the context of mootools and Classes, you may want to do a confirm class which works with events instead. If you want an example, give me a shout.

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

Sidebar

Related Questions

i developing an application in which i want to bind my own parameter with
I am developing an application in mootools. I have used Reqeust class to implement
I developing an android application in which i want to integrate faceebook and twitter.
I m using mootools 1.1 for developing joomla component. i want to get the
I am using Mootools extensively for a site which I am developing. But recently
Developing a project of mine I realize I have a need for some level
When developing whether its Web or Desktop at which point should a developer switch
When developing a new web based application which version of html should you aim
Developing for iPhone, I have a collection of points that I need to make
Developing iphone application using makkit framework. I have got the map view integrated in

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.