PDA

View Full Version : [3.3.1] createDelegate appendArgs not appending



mitchellsimoens
2 Mar 2011, 7:30 AM
I have a MessageBox Show pop up and want to pass extra parameters along with the button pressed.


var me = this;
Ext.Msg.show({
scope : me,
title : "Confirm Navigation",
msg : "Proceed?",
buttons : Ext.Msg.YESNO,
icon : Ext.MessageBox.QUESTION,
fn : me.doReload.createDelegate(me, [rec], true)
});

According to the API docs, the third parameter in the createDelegate, if set to true, will append the arguments in the second parameter to the default arguments. So it this case it would be like this:


doReload : function(btn, rec) {
....
}

and rec would be the Record I passed. However, when I console.log out the rec parameter in the doReload it was a blank string.

Now if I change the true to a number 1, the rec argument gets added as expected.


var me = this;
Ext.Msg.show({
scope : me,
title : "Confirm Navigation",
msg : "Proceed?",
buttons : Ext.Msg.YESNO,
icon : Ext.MessageBox.QUESTION,
fn : me.doReload.createDelegate(me, [rec], 1) //will send rec as 2nd argument
});

Condor
2 Mar 2011, 8:22 AM
This is not an error in createDelegate.

The problem is that the API documentation for the 'fn' option isn't clear.

The 'fn' callback is always called with 3 parameters:
1. The button name
2. The entered text (when used with prompt:true, otherwise an empty string)
3. The options used for showing the messagebox.

So using appendArgs:true would add your parameter in 4th position.

mitchellsimoens
2 Mar 2011, 8:26 AM
Ahh.. of course!

API docs are correct for the show method but not for the alert, confirm, and prompt.