How to open a new view on button click in sencha touch 2

萝らか妹 提交于 2019-12-11 14:38:35

问题


I am having two views

  1. Search.js with items fieldsets and a button
  2. ContactList.js with list of contacts

I have a controller Main.js

I want to implement a functionality in Sencha Touch 2 that, when button on Search.js is clicked, contact list from ContactList.js should be displayed. How do I do this?


回答1:


First of all, add an action or an id to your Search button in the view

{
    title: "My Button",
    xtype: 'button',
    action: 'call-contact-list',
}

Then in your controller, you need to implement what is going to happen when the button is clicked. Take the following code as an illustration. The code needs to be inside the control config:

control: {
   'button[action=call-contact-list]': {
            tap: 'myFunction'
        }
}

myFunction: function() {
    //Code to run when the button has been clicked. 
    //In this case, loading ContactList.js which should be something like this:
     Ext.Viewport.add({
         xtype: 'contactlist' //the xtype for the ContactList.js
     });
},


来源:https://stackoverflow.com/questions/11185667/how-to-open-a-new-view-on-button-click-in-sencha-touch-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!