【问题标题】:Sencha touch 2 - how to override the nestedlist tap event for a custom componentSencha touch 2 - 如何覆盖自定义组件的嵌套列表点击事件
【发布时间】:2012-06-15 17:34:52
【问题描述】:

我正在使用 getItemTextTpl 将复选框组件添加到嵌套列表 - 我还希望能够覆盖默认的点击事件,以便在选中复选框时显示弹出消息并且列表不会前进到下一个项目。请参阅下面的配置 - 我能够捕获复选框检查事件,但不知道如何覆盖嵌套列表的默认行为。感谢您的帮助,如果我能澄清任何细节,请告诉我 - 如果有帮助,我正在使用 sencha 架构师

嵌套列表配置:

getItemTextTpl: function(recordnode) {
        return '<table width="100%"><row>' + 
        '<tr><td width="100%" align="left" width="100%" valign="bottom"><div class="view"><input type="checkbox" <tpl  if="done">checked</tpl> />&nbsp;&nbsp;{name}</td></row></table>'; 

    }

控制器:

onNestedlistInitialize: function(component, options) {
// setup taskList to listen on the tap on the checkbox and show a popup window 
component.element.on({
    tap: function(e, el) {
        console.log('checkbox tapped'); 
        //need to override nestedlist tap event and show popup message
    }
});

【问题讨论】:

  • 你为什么不尝试覆盖 itemtap 事件?

标签: sencha-touch-2 sencha-architect


【解决方案1】:

为了防止列表切换到下一张卡片,您需要像这样覆盖 activeitemchange:

var nestedList = Ext.create('Ext.NestedList', {
  ...
  listeners:{
    activeitemchange:function(){
      if(...){ // Check if you checkbox is checked or not
         return false; // return false prevent the nestedlist from switching to the next view
      }
    }
  }
});

【讨论】:

  • 我在 Architect 中设置了一个 activeItemChange 事件,以覆盖您显示的列表切换,但仍需要以某种方式捕获复选框(或列表项上的按钮或其他表单元素)的点击事件) 在列表移动上返回 false 之前。在您的示例中,您正在检查是否已检查,但不应该检查是否已点击(可能还包括列表项上的复选框和标签)?再次感谢您帮助解决这个问题
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-14
  • 1970-01-01
  • 2013-05-05
  • 1970-01-01
  • 2023-04-01
相关资源
最近更新 更多