Sencha touch 使用ref getter函数返回未定义的
我仍在努力完成,但成功与否参差不齐。在我的控制器脚本中,我有以下内容:Sencha touch 使用ref getter函数返回未定义的,sencha-touch,sencha-touch-2,Sencha Touch,Sencha Touch 2,我仍在努力完成,但成功与否参差不齐。在我的控制器脚本中,我有以下内容: config: { refs: { notesListContainer: 'noteslistcontainer', noteEditor: 'noteeditor' }, control: { notesListContainer: { newNoteCommand: '
config: {
refs: {
notesListContainer: 'noteslistcontainer',
noteEditor: 'noteeditor'
},
control: {
notesListContainer: {
newNoteCommand: 'onNewNoteCommand',
editNoteCommand: 'onEditNoteCommand'
}
}
},
onEditNoteCommand: function(list, record) {
console.log('onEditNoteCommand');
this.activateNoteEditor(record);
},
activateNoteEditor: function(record) {
var noteEditor = this.getNoteEditor();
noteEditor.setRecord(record);
Ext.Viewport.animateActiveItem(noteEditor, this.slideLeftTransition);
},
当我在Chromium 18.0.1025.168中运行它时,我得到
Uncaught TypeError: Cannot call method 'setRecord' of undefined Notes.js:37`.
`this.getNoteEditor()'
不返回noteEditor,但返回未定义的
整个项目的源代码都可用。重要的是使用
autoCreate:true
config: {
refs: {
notesListContainer: 'noteslistcontainer',
noteEditor: {
selector: 'noteeditor',
xtype: 'noteeditor',
autoCreate: true // missing
}
},
},
...
}
在将那行代码添加到refs之后,我仍然得到相同的错误。我太急切了,在语法上犯了错误。主要思想是将表单定义为自动创建的