【问题标题】:"el" listener not working in Sencha Touch 2“el”监听器在 Sencha Touch 2 中不起作用
【发布时间】:2011-12-14 23:59:16
【问题描述】:

我正在使用 Sencha Touch 2.0-pr3。我无法让元素点击事件正常工作(请注意 BrowsePage 扩展了 Ext.Panel)。我很困惑,因为这在 Sencha Touch 1 中有效。有什么变化?!

var resultsPage = Ext.create('bla.myapp.BrowsePage', {
  id: 'searchResults',
  html: str,               
  listeners: {
    el: {
      tap: function() {
        console.log('hi!');
      }
    }
  }
})

【问题讨论】:

    标签: javascript dom-events sencha-touch sencha-touch-2


    【解决方案1】:

    Ext.Panel 不会触发 'tap' 事件。

    查看 Sencha Touch 2 API 文档,了解哪些类触发了哪些事件:

    http://docs.sencha.com/touch/2-0/#!/api/Ext.Panel

    【讨论】:

    • API文档不是很完整..你得看源码。
    【解决方案2】:

    有人在这里回答了我的问题:http://www.sencha.com/forum/showthread.php?161806-%E2%80%9Cel%E2%80%9D-listener-not-working-in-Sencha-Touch-2&p=691670&viewfull=1#post691670

    它还没有在 ST2 中,所以现在覆盖 initialize() --

    initialize: function() {
        this.callParent();
    
        this.element.on({
        ...
        });
    }
    

    【讨论】:

    • 嗨,这真的在没有 MVC 的情况下解决了。但是我在哪里把我的控制器放在哪里?这不起作用:control: {panelContainer: { tap: 'ChangeProjectOu' }}
    【解决方案3】:

    试试这个

    var resultsPage = Ext.create('bla.myapp.BrowsePage', {
      id: 'searchResults',
      html: str,               
      listeners: {
        tap: {
            element: 'element',
            fn: function(e) {
                console.log('hi!');
            }
        }
    }
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-19
      相关资源
      最近更新 更多