zoukankan      html  css  js  c++  java
  • ux.plugin.ConTpl 模版元素监听扩展

     1 /*
     2 *tpl模版加入按钮
     3 *<div class="x-button-normal x-button x-iconalign-center x-layout-box-item x-stretched btn" style="visibility:{visibility}" fire="TasteUp" ><span class="x-button-icon x-shown lower"></span></div>
     4 *fire="tasteUp" 表示添加tasteUp事件和激活dotasteUp方法
     5 *有两个参数cmp:视图本身以及doit
     6 *只要是以上格式的模板都可以被监控到
     7 *其中btn、shareIco为自定义样式,其他都是st自带样式
     8 */
     9 Ext.define('ux.plugin.ConTpl', {
    10     alias: 'plugin.conTpl',
    11     xtype: 'conTpl',
    12     config: {
    13         cmp: null,
    14         //按下时添加css
    15         pressedCls: 'pressing',
    16         //监控对象选择器
    17         delegate: 'div.fire'
    18     },
    19     constructor: function (config) {
    20         this.initConfig(config);
    21         this.callParent([config]);
    22     },
    23     //初始化
    24     init: function (cmp) {
    25         this.setCmp(cmp);
    26     },
    27     //更新配置
    28     updateCmp: function (newCmp, oldCmp) {
    29         if (newCmp) {
    30             newCmp.on({
    31                 //只有创建完成后才能监听事件
    32                 render: 'onRender',
    33                 scope: this
    34             });
    35         }
    36     },
    37     //创建完成
    38     onRender: function (t, eOpts) {
    39         t.el.on({
    40             click: 'onTap',
    41             delegate: this.getDelegate(),
    42             scope: this
    43         });
    44     },
    45     //执行动作
    46     onTap: function (e) {
    47         var cmp = this.getCmp(),
    48         el = e.getTarget(this.getDelegate(), null, true),
    49         fire = el.getAttribute('fire');
    50         cmp.fireEvent(fire, cmp, el);
    51     }
    52 });
  • 相关阅读:
    给js function的参数设置默认值
    如何让windows服务器IIS支持.apk/.ipa文件下载
    Firefox 设置技巧
    在sql中使用了 hashbytes 函数
    SQL Server 查询处理中的各个阶段(SQL执行顺序)
    Jquery 操作 radio选中值
    gradle更新依赖库
    weex第一节-环境搭建
    安装weex-toolkit老是失败的解决办法
    Android透明度颜色值计算
  • 原文地址:https://www.cnblogs.com/mlzs/p/5595789.html
Copyright © 2011-2022 走看看