Shlomo
Shlomo

Reputation: 3990

Add parameter to MessageBox prompt

I use this prompt statement and want to pass another variable to callback function:

Normal behaviour:

Ext.MessageBox.prompt('Name', 'New folder name:', this.callbackCreateFolder);

callbackCreateFolder: function(btn, text) {
         console.log( btn ); // value as expected
         console.log( text ); // value as expected
}

What I want:

Ext.MessageBox.prompt('Name', 'New folder name:', this.callbackCreateFolder(oRecord));
callbackCreateFolder: function(btn, text, oRecord) {
         console.log( btn ); // undefined
         console.log( text ); // undefined
         console.log( oRecord ); // value as expected
}

What is the best way to pass additional parameters to the function?

Upvotes: 1

Views: 1781

Answers (1)

Evan Trimboli
Evan Trimboli

Reputation: 30082

Ext.require('*');

function foo(btn, text, s1, s2) {
    console.log(s1, s2);
}

Ext.onReady(function(){
    Ext.MessageBox.prompt('Name', 'New folder name:', Ext.Function.bind(foo, null, ['bar', 'baz'], 2));
});

Upvotes: 3

Related Questions