PDA

View Full Version : callback event question?



skyey
28 Jun 2007, 9:13 AM
Ext.onReady(function(){
Ext.get('mb1').on('click',test);

function test(e){
var bl=false;
Ext.MessageBox.confirm('Confirm', 'Are you sure you want to do that?',function(btn){
if(btn=='yes'){
bl = true;
}
});

if(!bl){// bl always = false, i didn't want to prevent event when click ok button.
e.preventDefault();
alert('aa');
}


}

});

matjaz
28 Jun 2007, 9:17 AM
you're missing a point... function is invoked when you click on button... while if(!bl) is executed right after showing confirm box.

skyey
28 Jun 2007, 9:31 AM
i changed but still wrong

function test(e){
Ext.MessageBox.confirm('Confirm', 'Are you sure you want to do that?',tx.createDelegate(e));

}

function tx(btn,e){
if(btn=='yes'){
e.preventDefault();//here wrong,what can i do?
bl = true;
}
}
});