SenchaTouch2のMVC構造は初めてです。
私の見解では、私は次のようなラベルを持っています:
{xtype:'label'、itemId:'title'、html:'title'}
私のコントローラーで、このラベルの値を設定するにはどうすればよいですか?
現在、私のコントローラー(チュートリアルサンプルを作成中):
Ext.define( "NotesApp.controller.Notes"、{
extend: "Ext.app.Controller", config: { refs: { // We're going to lookup our views by xtype. noteView: "noteview", noteEditorView: "noteeditorview", notesList: "#notesList" }, control: { noteView: { // The commands fired by the notes list container. noteNextCommand: "onNoteNextCommand", noteAnswerCommand: "onNoteAnswerCommand" }, noteEditorView: { // The commands fired by the note editor. saveNoteCommand: "onSaveNoteCommand", deleteNoteCommand: "onDeleteNoteCommand", backToHomeCommand: "onBackToHomeCommand" } } }, onNoteNextCommand: function () { var noteView = this.getNoteView(); console.log("loaded view"); //set label here }, // Base Class functions. launch: function () { this.callParent(arguments); var notesStore = Ext.getStore("Notes"); notesStore.load(); console.log("launch"); }, init: function () { this.callParent(arguments); console.log("init"); } });
完全なビューコード:
Ext.define( "NotesApp.view.Note"、{extend: "Ext.Container"、alias: "widget.noteview"、
config: { layout: { type: 'fit' }, items: [ { xtype: "toolbar", title: "Random Question", docked: "top", items: [ { xtype: 'spacer' }, { xtype: "button", text: 'List', ui: 'action', itemId: "list" } ] }, { xtype: "label", html: 'question', itemId: "question" }, { xtype: "label", html: 'answer', itemId: "answer" } ], listeners: [{ delegate: "#list", event: "tap", fn: "onListTap" }, { delegate: "#question", event: "tap", fn: "onQuestionTap" }, { delegate: "#answer", event: "tap", fn: "onAnswerTap" }] }, onListTap: function () { console.log("list"); this.fireEvent("showList", this); }, onQuestionTap: function () { console.log("noteAnswer"); this.fireEvent('noteAnswer', this); }, onAnswerTap: function () { console.log("noteNext"); this.fireEvent('noteNext', this); } });