我的UI中有一个TextArea和一个DatePicker。每当TextArea获得焦点时,我都会尝试显示/隐藏DatePicker。这是代码片段:
/*global Ext:false */
Ext.onReady(function () {
var textArea = Ext.create('Ext.form.field.TextArea', {
width: 200,
height: 20,
renderTo: Ext.getBody(),
listeners: {
'focus': function() {
var datePicker = Ext.ComponentQuery.query('#datepicker')[0];
if (datePicker.isVisible())
datePicker.hide();
else
datePicker.show();
}
}
});
var datePicker = Ext.create('Ext.menu.DatePicker', {
renderTo: Ext.getBody(),
itemId: 'datepicker',
handler: function (dp, date) {
textArea.setValue ('You selected ' + Ext.Date.format(date, 'M j, Y'));
}
});
});
最初,DatePicker是可见的,因此'focus'事件的回调代码执行得很好,并隐藏了DatePicker。但是,当TextArea第二次获得焦点时,我收到以下错误:
TypeError: 'undefined' is not an object (evaluating 'D[z.parallelBefore]')
calculateChildBoxesext-all.js:15:353261
onLayoutext-all.js:15:356219
layoutext-all.js:15:233311
doLayoutext-all.js:15:316709
showext-all.js:15:310075
focusapp.js:15
fireext-all.js:15:241297
continueFireEventext-all.js:15:159467
fireEventext-all.js:15:159245
onFocusext-all.js:15:756851
callParentext-all.js:15:65228
onFocusext-all.js:15:760411
anonymous
cext-all.js:15:127065
app.js:23
我认为错误在'焦点'函数回调中,但我不确定如何解决它。我是ExtJS / Sencha noob。有什么想法吗?