PDA

View Full Version : Ext.MessageBox.alert within a Ext.MessageBox.confirm



joe123
7 May 2010, 12:00 AM
Hi,


I am trying to get a 'messgebox alert' within a 'messagebox confirm' to
show something actually happened. But it does not do anything....

Code is like this:


Ext.MessageBox.confirm('Confirm', question, function(btn, text){

if (btn == 'yes'){
//do something and check for the result
if(result){
Ext.MessageBox.alert('Message', result.okmessage);
else{
Ext.MessageBox.alert('Message', result.errormessage);
}
}
});In the 'do something part' I do an AJAX request and the 'if result' part is within the success part of that request.
It has probably something to do with the scope or something....but dont know what exactly.

Thnx!

Condor
7 May 2010, 12:25 AM
Are you sure you get to the success handler, or is the failure handler called?

If that isn't it, could you also post the 'do something' part?

jtpacheco
7 May 2010, 7:43 AM
What is "result"?

If you're using the "success : " part correctly, you should be doing "success : function(resp, opt){}" where resp is the response and opt is the parameters you passed (specifically, opt.params.<param name>).

So if you are doing that, "result" should be "resp.responseText = <something>" if you're getting text back from the request.

Most probably, "result" is undefined. One debugging method that works for me when I can't be bothered to step through with firebug is to just do "alert(<object>);" or in this case, "alert(result);" It will display what result is, either undefined (highly likely) or some text if its a var, or [object Object] if its a complex object.

EDIT: sometimes, if an object or var that's being used is undefined, it will cause the entire script to seize. The upside of this is that if you use Firebug, it will display it as an error, and you can easily see what it is. I highly recommend that you use Firebug at some point, as it is a much more complete debugging tool than just throwing alerts everywhere :)