Extjs使用Ext.function.bind, 给句柄函数传参

时间:2023-03-09 07:08:46
Extjs使用Ext.function.bind, 给句柄函数传参

回调函数updateImage中的key参数,在外部调用时有程序员自己指定.

使用Ext.Function.bind(this.updateImage, this, 'imageUrl', true)

参数一:updateImage函数引用,

参数二:this(固定写法)

参数三:程序员自定义updateImage函数引用中的key参数值

参数四:true (固定写法)

showSelectImageWindow: function() {
var me = this.getView();
this.selectImage(Ext.Function.bind(this.updateImage, this, 'imageUrl', true));
}, showSelectLogoWindow: function() {
var me = this.getView();
this.selectImage(Ext.Function.bind(this.updateImage, this, 'logoUrl', true));
}, showSelectPhotoWindow: function() {
var me = this.getView();
this.selectImage(Ext.Function.bind(this.updateImage, this, 'bzLicensePhotoUrl', true));
}, selectImage: function(callback) {
if (!this.imgWindow) {
this.imgWindow = Ext.create('app.ux.window.SelectImageWindow', {
callback: callback
});
} else {
Ext.apply(this.imgWindow, {callback: callback});
}
this.imgWindow.show();
}, updateImage: function(url, title, uploadId, key) {
this.getView().getViewModel().set(key, url);
},