1

Sencha Touch を初めて使用または悪用していますが、ボタンをクリックしたときにリストビューをプッシュしたいだけです。これが私の見解です:

Ext.define('TouchNuts.view.Decision', {
extend: 'Ext.Panel',
xtype: 'decision',

config: {
    title: 'Decision',

    scrollable: true,
    styleHtmlContent: true,
    styleHtmlCls: 'Decision',
    tpl: '<h2>{name}</h2>, <h3>{description}<h3>, <h4>{price:ellipsis(15)}</h4> <h1>you can do this </h1>',



        items: [

                        {
                        xtype: 'button',
                        text: 'SEND',
                        ui: 'confirm',
                        docked: 'bottom',
                        action:  'doSomething'
                        }
               ]
         }
 });

プッシュしたいビューは次のとおりです。

Ext.define('TouchNuts.view.File', {
extend: 'Ext.Panel',
xtype: 'file',

config: {
    title: 'File',
    iconCls: 'star',
    layout: 'fit',
            items: [
                {
                        xtype: 'list',
                        id: 'file',
                        store: 'TransactionStore',
                        itemTpl: '<h2>{name:ellipsis(15)}</h2>, <h3>{description:ellipsis(8)}<h3>, <h4>{price:ellipsis(15)}</h4>',
                        itemCls: 'SummaryItems'
                }
            ]
    }
});

そして、ここに私のコントローラーがあります:

Ext.define('TouchNuts.controller.doSomething', {
extend: 'Ext.app.Controller',

config: {
    refs: {

    },
        control: {
          'button[action=doSomething]' : {
             tap: function() {
               getMainView('TouchNuts.view.Decision').push('TouchNuts.view.File');

             }
         }

}
}
});

HTML、CSS、jQuery はかなり得意ですが、JS は初めてで、Sencha に関してはまったく無知なので、アドバイスをいただければ幸いです。

4

2 に答える 2

2

コントローラでビューを参照するために、ビューにitemIdを指定することをお勧めします。たとえば、次のようになります。

TouchNuts.view.DecisionitemIdを持つことができます:decisionPanel

TouchNuts.view.FileitemIdを持つことができます:filePanel

今あなたの中であなたControllerはこれをするでしょう:

...
config: {
    refs: {
       decisionPanel: {
           autocreate: true,
           selector: '#decisionPanel',
           xtype: 'decision'
       },    
       filePanel: {
           autocreate: true,
           selector: '#filePanel',
           xtype: 'file'               
       }
    },
    control: {
      'button[action=doSomething]' : {
         tap: 'onButtonTap'
     }

}

onButtonTap : function(button, e, options) {
    var me = this;
    Ext.Viewport.setActiveItem(me.getDecisionPanel());
}
...

getDecisionPanel()あなたは私がビューを取得するために使用したことに気付くでしょうdecisionPanel。これは、getter関数がref指定するたびに自動的に生成され、それにアクセスするために、get+大文字のref名前を使用するのが初めてであるためです。詳細はこちら: http: //docs.sencha.com/touch/2-1/# !/api/Ext.app.Controller

于 2013-02-03T06:19:52.963 に答える
1

それ以外の

getMainView('TouchNuts.view.Decision').push('TouchNuts.view.File');

最初にビューを作成してから、ビューにプッシュする必要があります

getMainView('TouchNuts.view.Decision').push(Ext.create('TouchNuts.view.File'));
于 2013-02-03T10:46:27.640 に答える