zoukankan      html  css  js  c++  java
  • 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);
        },
  • 相关阅读:
    Highcharts之饼图
    设计模式学习之原型模式
    jQuery学习之结构解析
    JS学习之闭包的理解
    JS学习之prototype属性
    JS学习之事件冒泡
    Mybatis学习之JDBC缺陷
    Spring学习之Aop的基本概念
    Struts学习之值栈的理解
    Struts学习之自定义结果集
  • 原文地址:https://www.cnblogs.com/cocoat/p/5166984.html
Copyright © 2011-2022 走看看