我想从我的 Sencha Touch 2 控制器中获得对我的视图的引用,它看起来像这样(CoffeeScript):
Ext.define 'MyApp.view.Books',
extend: 'Ext.Panel'
id: 'books'
config:
html: 'Hello, Books!'
Ext.define 'MyApp.controller.Books',
extend: 'Ext.app.Controller'
views: [
'Books'
]
init: ->
@control
'#books':
render: ->
console.log 'This is never called. Why?'
show: ->
console.log 'This is called twice.'
# @getBooksView() is not a view instance, it is a class. Why?
console.log 'View class: ' + @getBooksView()?.$isClass
Ext.application
name: 'MyApp'
controllers: [
'Books'
]
launch: ->
Ext.Viewport.setActiveItem
xtype: 'booksview'
'Hello, Books' 内容出现(例如,组件被渲染),但渲染控制处理程序甚至从未被调用。我在这里做错了什么?