PDA

View Full Version : sos!!! Uncaught TypeError: Cannot call method 'substring' of undefined



jhjiang@163.com
14 Oct 2012, 6:33 PM
<sup></sup><sub></sub>
Ext.define('Ext.ux.datetime.DateTimeField', {<div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp;extend: 'Ext.form.field.Date',</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp;alias: 'widget.datetimefield',</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp;requires: ['Ext.ux.datetime.DateTimePicker'],</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp;initComponent: function() {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp;this.format = this.format + ' ' + 'H:i:s';</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp;this.callParent();</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp;},</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp;// overwrite</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp;createPicker: function() {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp;var me = this,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp;format = Ext.String.format;</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp;return Ext.create('Ext.ux.datetime.DateTimePicker', {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp; &nbsp;ownerCt: me.ownerCt,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp; &nbsp;renderTo: document.body,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp; &nbsp;floating: true,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp; &nbsp;hidden: true,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp; &nbsp;focusOnShow: true,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp; &nbsp;minDate: me.minValue,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp; &nbsp;maxDate: me.maxValue,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp; &nbsp;disabledDatesRE: me.disabledDatesRE,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp; &nbsp;disabledDatesText: me.disabledDatesText,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp; &nbsp;disabledDays: me.disabledDays,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp; &nbsp;disabledDaysText: me.disabledDaysText,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp; &nbsp;format: me.format,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp; &nbsp;showToday: me.showToday,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp; &nbsp;startDay: me.startDay,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp; &nbsp;minText: format(me.minText, me.formatDate(me.minValue)),</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp; &nbsp;maxText: format(me.maxText, me.formatDate(me.maxValue)),</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp; &nbsp;listeners: {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp; &nbsp;scope: me,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp; &nbsp;select: me.onSelect</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp; &nbsp;},</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp; &nbsp;keyNavConfig: {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp; &nbsp;esc: function() {</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp; &nbsp;me.collapse();</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp; &nbsp;}</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp; &nbsp;}</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp; &nbsp;});</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> &nbsp;}</div>&nbsp; });<br><br>i use it like this&nbsp;<br><br><br>
{<div><span class="Apple-tab-span" style="white-space:pre"> </span>xtype : 'datetimefield',</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>fieldLabel : '开始时间',</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>id : 'publishStartTime',</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>editable : false,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>format : 'Y-m-d',</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>anchor : '100%',</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>width : 200,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>labelWidth : 60</div><span class="Apple-tab-span" style="white-space: pre; "> </span>}<br><br>and i load it too&nbsp;<br>
Ext.Loader.setConfig({<div><span class="Apple-tab-span" style="white-space:pre"> </span>enabled : true</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>});</div><div>Ext.Loader.setPath('Ext.ux', '../../../static/jslib/extjs-4.1.0/ux');</div><div>Ext.Loader.setPath('Ext.components', '../../../static/commonjs/components');</div><div>Ext.Loader.setPath('Ext.notify', '../../../scripts/sysmng/notify/components');</div><div>Ext.require(['Ext.data.*', 'Ext.grid.*', 'Ext.tree.*','Ext.ux.RowExpander',</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>'Ext.ux.datetime.DateTimeField', 'Ext.components.BaseDataComboBox',</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>'Ext.components.BaseCommonPagingToolbar',</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>'Ext.notify.addNotificationWin',</div><span class="Apple-tab-span" style="white-space: pre; "> </span>'Ext.notify.showNotificationDetailWin', 'Ext.notify.logWin']);<br><br>it can work in ff but in ie and chrome i will get "&nbsp;Uncaught TypeError: Cannot call method 'substring' of undefined" error .<br>help &nbsp;help !!!!

jhjiang@163.com
14 Oct 2012, 6:38 PM
Ext.define('Ext.ux.datetime.DateTimeField', { extend: 'Ext.form.field.Date', alias: 'widget.datetimefield', requires: ['Ext.ux.datetime.DateTimePicker'],
initComponent: function() { this.format = this.format + ' ' + 'H:i:s'; this.callParent(); }, // overwrite createPicker: function() { var me = this, format = Ext.String.format;
return Ext.create('Ext.ux.datetime.DateTimePicker', { ownerCt: me.ownerCt, renderTo: document.body, floating: true, hidden: true, focusOnShow: true, minDate: me.minValue, maxDate: me.maxValue, disabledDatesRE: me.disabledDatesRE, disabledDatesText: me.disabledDatesText, disabledDays: me.disabledDays, disabledDaysText: me.disabledDaysText, format: me.format, showToday: me.showToday, startDay: me.startDay, minText: format(me.minText, me.formatDate(me.minValue)), maxText: format(me.maxText, me.formatDate(me.maxValue)), listeners: { scope: me, select: me.onSelect }, keyNavConfig: { esc: function() { me.collapse(); } } }); } });

i use it like this

{ xtype : 'datetimefield', fieldLabel : 'startTime', id : 'publishStartTime', editable : false, format : 'Y-m-d', anchor : '100%', width : 200, labelWidth : 60 }
and i load the components too .

Ext.Loader.setConfig({ enabled : true });Ext.Loader.setPath('Ext.ux', '../../../static/jslib/extjs-4.1.0/ux');Ext.Loader.setPath('Ext.components', '../../../static/commonjs/components');Ext.Loader.setPath('Ext.notify', '../../../scripts/sysmng/notify/components');Ext.require(['Ext.data.*', 'Ext.grid.*', 'Ext.tree.*','Ext.ux.RowExpander', 'Ext.ux.datetime.DateTimeField', 'Ext.components.BaseDataComboBox', 'Ext.components.BaseCommonPagingToolbar', 'Ext.notify.addNotificationWin', 'Ext.notify.showNotificationDetailWin', 'Ext.notify.logWin']);
this code can work in ff ,
but in ie and chrome it will catch the error"Uncaught TypeError: Cannot call method 'substring' of undefined"
i have struggle in it 10 hours ...help me !!!!!!!!

scottmartin
16 Oct 2012, 5:41 AM
Uncaught TypeError: Cannot call method 'substring' of undefined

This generally means you are trying to access something by type and it is not found.
eg: xtype, etc.

Please verify all of your loader paths are correct and your components are in that path.

If you use ext-dev.js in your html, it will display warning messages in your console as well.

Scott.