2012-05-23 137 views
0

我試圖做同樣的應用程序與miamicode之間切換,我在第3步 http://miamicoder.com/2012/how-to-create-a-sencha-touch-2-app-part-3/煎茶觸摸 - 觀點

我儘量讓這變爲新的筆記(開關按鈕,一個新的屏幕,創建一個新的註釋)

在例子中的代碼是這樣的:

onNewNoteCommand: function() { 
    console.log("onNewNoteCommand"); 
    var now = new Date(); 
    var noteId = (now.getTime()).toString() + (this.getRandomInt(0, 100)).toString(); 
    var newNote = Ext.create("NotesApp.model.Note", { 
      id: noteId, 
      dateCreated: now, 
      title: "", 
      narrative: "" 
     }); 

     this.activateNoteEditor(newNote); 
    } 

的activateNotesList功能是這樣的:

activateNotesList: function() { 

    Ext.Viewport.animateActiveItem(this.getNotesListView(), this.slideRightTransition); 

我自己的例子,我試着去編輯視圖而不傳遞數據。 ,所以我試試這個:

onNewNoteCommand:function() 

{ 
var noteEditor = this.getNoteEditor(); 

// Ext.Viewport.add(noteEditor); also tried this. 

Ext.Viewport.setActiveItem(noteEditor); 

的代碼沒有任何錯誤運行,但屏幕不會改變。 有什麼建議嗎?添加什麼差異?

我如何設置視口(還沒有創建任何自定義視口)卡?這是setactiveitem不起作用的問題嗎?任何其他方式來切換視圖?

回答

1

在Chrome瀏覽器的控制檯中是否存在一些錯誤? Ctrl+Shift+J打開。

此外,您還必須檢查noteEditor是否等於對象或數字。

來自sencha文檔:setActiveItem(Object/Number activeItem)

+0

以及我沒有錯誤。 但noteEditor的類型是undifiend ... 這是我noteEditor如何開始: Ext.define( 「noteditor.view.NoteEditor」,{ 擴展: 「Ext.form.Panel」, 別名: 「widget.noteeditor」, \t要求: 「Ext.form.FieldSet」, \t \t 配置:{佈局:{類型: 'VBOX'}}, \t初始化:功能(){.. ... 和控制器我有一個參考 Ext.define( 「noteditor.controller.Notes」,{ 延伸: 「Ext.app.Controller」, \t配置:{ \t \t參:{ \t \t \t notesListContainer: 「主」, \t \t \t noteEditor: 「noteeditor」 \t \t \t}, \t \t控制:{ \t \t \t \t \t \t \t \t}}, – Giannis

+0

我不應該用這個ref得到一個noteeditor視圖嗎? – Giannis

+0

你應該這樣寫:Ext.define(「noteditor.view.NoteEditor」,{extend:「Ext.form.Panel」,xtype:'noteeditor'.....並且你的ref noteEditor不會被定義爲 –