-
23 Sep 2010 6:22 AM #1
[CLOSED]Ext.History.init() bug?
[CLOSED]Ext.History.init() bug?
Just attempted to use Ext.History (ext 3.2.1), and get this error when calling init (from chrome) :
Plain index.html included nothing but:PHP Code:Uncaught TypeError: Cannot read property 'value' of null
startUp ext-all-debug.js:30124
init ext-all-debug.js:30176
(anonymous function) index.html:17
call
The fix as I would guess it, would be to change line 30145 (in ext-all-debug.js) from:PHP Code:<script type="text/javascript">
Ext.onReady(function(){
Ext.History.init();
});
</script>
toPHP Code:fieldId: 'x-history-field',
Which appears to work for me, at least.PHP Code:fieldId: {value : 'x-history-field'},
Last edited by ody; 23 Sep 2010 at 6:22 AM. Reason: forgot to mention the name of the file that the change needs to be made in.
-
23 Sep 2010 6:33 AM #2
Actually, it looks like it is something to do with the DOM element id:x-history-field not existing .. which I can see CSS for but nothing that creates the element. If I create a div in the body with id x-history-field all works as expected.
-
23 Sep 2010 6:41 AM #3
I've put this in at line 30165ish:
I'm new to all this so not really sure if this is the best possible fix, would love some input either way.PHP Code:if(!hiddenField || hiddenField == null)
{
Ext.DomHelper.append('body', {tag: 'div', id: "x-history-field"});
hiddenField = Ext.getDom(Ext.History.fieldId);
}
-
23 Sep 2010 6:50 AM #4
It is not a bug, Ext.History class is designed that way.
By looking at a part of init() code:
There is nothing creating the element, letting that task up to the developer.Code:hiddenField = Ext.getDom(Ext.History.fieldId); if (Ext.isIE) { iframe = Ext.getDom(Ext.History.iframeId); }
It would still be a valid question to ask why they choosed not to create elements required by Ext.History automatically...
-
23 Sep 2010 7:00 AM #5
ExtJS is to good, I keep making assumptions it's taking care of things.
-
23 Sep 2010 7:01 AM #6
You should never directly modify the ext code since you will lose changes when updating the library.
You should simply override the class methods that you want using Ext.override().
In this specific case, you could only add this code to the Ext.onReady() function:
*Note: Ext.History class needs an hidden input field, not a div element.
You can also create an interceptor to Ext.History.init() function that would create the element before processing the function.Code:Ext.DomHelper.append('body', {tag: 'input', type:'hidden', id: "x-history-field"});
Look at the createInterceptor doc here.Code://Something like this Ext.History.init = Ext.History.init.createInterceptor(function(){ Ext.DomHelper.append('body', {tag: 'input', type:'hidden', id: "x-history-field"}); });
-
23 Sep 2010 11:21 AM #7
thanks scarsick! funnily I've learnt a lot by not RTFM :P
-
24 Sep 2010 1:33 AM #8
This interceptor function has given me an idea..
Every time I run into problems like these I'll simply add a test case to Ext.Debug. This can then be used by others to quickly pick up on common mistakes.PHP Code:Ext.ns('Ext.Debug');
Ext.Debug = function(){
Ext.History.init = Ext.History.init.createInterceptor(function(){
hiddenField = Ext.getDom(Ext.History.fieldId);
if(!hiddenField || hiddenField == null)
{
alert('Ext.History.init: no hidden field defined.');
return false;
}
return true;
});
Ext.apply = Ext.History.init.createInterceptor(function(o, c, defaults){
if(typeof o != "object" || typeof c != "object")
{
alert('Ext.apply: arguments must be of type object.');
return false;
}
return true;
});
}();
I've got this feeling that someone is going to tell me this has already been done :-D
-
24 Sep 2010 6:05 AM #9
I like the idea... this pattern could almost be used in the entire framework to give custom error messages that would help fixing bugs, without having the code polluted with error checking code.
-
24 Sep 2010 6:15 AM #10
Do you or any mods/devs know the best way to get something like this off the ground? I know I could slap it on googlecode and add test cases as I stumble over the ExtJS library but that doesn't feel like it would be the best way forward.
Maybe starting a new thread somewhere asking for input from the community?
You found a bug! We've classified it as
a bug in our system.
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
Similar Threads
-
[STALE-772] ext.history bug inside IE when using viewport?
By ykoehler in forum Ext 3.x: BugsReplies: 2Last Post: 20 Aug 2010, 7:07 AM -
Ext.History IE back/forward bug
By ykoehler in forum Ext 3.x: Help & DiscussionReplies: 0Last Post: 23 Mar 2010, 9:15 AM -
[INFOREQ] Ext.History bug
By poopsmith in forum Ext 3.x: BugsReplies: 2Last Post: 12 Mar 2010, 12:43 PM -
[2.3.0] Ext.History Encoding Bug
By Teimur in forum Ext 2.x: BugsReplies: 1Last Post: 4 Feb 2010, 8:40 AM -
[CLOSED] DateField Init Bug
By TheBuzzer in forum Ext GWT: Bugs (1.x)Replies: 1Last Post: 3 Sep 2008, 8:11 AM


Reply With Quote