1. #1
    psaraf
    Guest

    Default Alternate way for Confirmation Box

    Alternate way for Confirmation Box


    Hi,
    I have a situation, when some one click on link(anchor) it should ask for confirmation. if i do normal way of JS it works fine because my method calls JS confirm() function, return true or false, if I use Ext Confirmation box, it won't stop the execution and goes ahead.
    What is solution if i want to use Ext Confirmation box?

    I know that MessageBox is asynchronous and it did not stop the execution. i just need an alternate and easy way to do it.

    My Code
    HTML
    Code:
    <a href="begin.do" onclick="return deleteAlert()>Delete</a>
    Ext Code
    Code:
        returnVar = false;
        deleteAlert = function(){
             Ext.MessageBox.confirm('Confirm', 'Are you sure you want to delete  it >",validateConfirm);        
             return returnVar;
        }
        function validateConfirm(bn)
        {       
            if(bn == "yes")
            {      
                returnVar =  true;
            }
            else
            {   
              returnVar = false;
            }
        }

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,647
    Vote Rating
    583
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    That's not how it works.

    You'll need to do something like:

    Code:
    //get all anchors on the page
    Ext.select('a').on('click', function(e)
    {
       e.stopEvent(); //stop the event
       Ext.MessageBox.confirm('foo', 'bar', function(btn)
       {
          if (btn == 'yes')
             document.location.href = e.getTarget().href;
       }
       );
    }
    );
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

Thread Participants: 1