我使用此提示语句并希望将另一个变量传递给回调函数:
正常行为:
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
}
我想要的是什么:
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
}
将其他参数传递给函数的最佳方法是什么?
答案 0 :(得分:3)
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));
});