【问题标题】:Sencha Touch - Calling function within view does not get calledSencha Touch - 视图内的调用函数不会被调用
【发布时间】:2013-02-01 10:35:05
【问题描述】:

我刚刚开始探索煎茶。坚持这一点。帮助赞赏:)

这是我的 java 脚本代码,在下面的行处理程序函数中,我正在调用以下方法,该方法位于 items 和 parent xtype form-panel 下。

  {
     xtype:'panel',
     defaults:{
        xtype:'button',
        style:'margin: 0.1em',
        flex:1
     },
     layout:{
        type:'hbox',
        align:'center'
     },
     items:[
        {
           text:'Submit',
           handler:this.makeReq,
           scope:this
        },
        {
           text:'Terms & Conditions',

        }
     ]
  }

这是在上述函数中调用的方法,但似乎没有发生任何事情。

makeReq: function() {
    alert("Hey There");
}

【问题讨论】:

    标签: javascript extjs sencha-touch sencha-touch-2


    【解决方案1】:

    我真的建议你在这种情况下遵循 Sencha Touch 2 MVC 模型。你可以给你的按钮一个这样的动作:

    {
        text:'Submit',
        action: 'submit'
    }
    

    然后您可以引用此按钮并在应用的控制器中为其设置功能:

    config: {
        refs: {
            submitButton: 'button[action=submit]',
        },
    
        control: {
            submitButton: {
                tap: 'makeReq'
            },
        },
    
        makeReq: function() {
            alert("Hey There");
        }
    }
    

    【讨论】:

    • 错了,你需要把代码放在你的控制器里,而不是你的视图里。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多