use dialog confirmation as confirm dialog

use dialog confirmation as confirm dialog

Hello,

I want to use a jquery ui dialog popup for confirmation, but i can't use this like I want.
I want to do this :
  1. function popup() {
          $("#test").dialog({
                modal: true,
                title: "Test",
                buttons: {
                  "CANCEL": function() {
                    $("#test").dialog( "close" );
                    return false;
                  },
                  "OK": function() {
                    $("#test").dialog( "close" );
                      return true;
                  }
          }
        });
    }














And use like this :

  1. if(popup()) {
  2.       // do some stuff
  3. }else{
  4.       // do some other stuff
  5. }
But it doesn't work.
If you have any ideas,

Thanks,

Thec