PDA

View Full Version : [2.2][CLOSED] Quicktips.init throws tip not defined error when called on page load.



schoterson
11 Aug 2008, 2:28 PM
In ext-2.1 and 1.1.1 for that matter I had no problem doing this


Ext.EventManager.addListener(window, 'load',Intranet.framework.Core.initializePage, Intranet.framework.Core);

Intranet.framework.Core.initializePage = function() {

console.log("initing page methods");
// half dozen calls to methods, followed by the quicktips init.
Ext.QuickTips.init();
}

however in ext-2.2 this seems to cause an issue, specifically:
tip has no property
tip.register.apply(tip, arguments);

After editing ext-all-debug to add in some alerts to the Ext.QuickTips.init it seems to me that the check for onReady causes an issue.

I would expect to see the first warning about tip not being defined and that is it, since my call to init is after the windows load event. however I see the 2nd warning and then the error message. If I see the 2nd warning I'd expect to see the 1st one again since its a recursive call to the init function, but I never do. Is the return line screwing this up?



init : function(autoRender){

if(!tip){
console.warn("initing quicktips and tip isn't defined");
if(!Ext.isReady){
console.warn("initiing quicktips document is NOT ready");
Ext.onReady(function(){
console.log("re-initing quicktips");
Ext.QuickTips.init(autoRender);
});
return;
}
tip = new Ext.QuickTip({elements:'header,body'});
if(autoRender !== false){
tip.render(Ext.getBody());
}
}
}

My solution was to move the call to the Ext.QuickTips.init() method out of my initializePage method so its not called via the onload event, which is probably the better thing to do anyways, so now I guess I'm just curious.

Condor
11 Aug 2008, 9:33 PM
Could you explain why you are using a load eventhandler instead of using Ext.onReady?

schoterson
12 Aug 2008, 9:33 AM
In 1.1.1 which is what our existing framework is based on we had JS timing issues with onready when loading in IE, so we moved to the more standard onload event listener. I've tried onready and onload in our rewritten framework using 2.1 I without any issues but noticed that the perceived load time of the page seemed quicker using the onload event in IE6.

Unfortunately our IT group hasn't approved the use of IE7 and IE6 is the market leader within our company, so we've stuck with the onload event. Since we are in the midst of rewriting our framework when ext-2.2 was released we changed our references and this tip issue is the only one we've encountered so far.

brian.moeskau
23 Sep 2008, 11:20 PM
The logic in QuickTips is correct, so I imagine that you are seeing an onReady-specific issue and the fact that it's happening in QuickTips is probably coincidental. There were some changes to onReady in 2.2 and there's an ongoing discussion in this thread (http://extjs.com/forum/showthread.php?t=43246) about it. The current version of onReady in SVN should be back to working as it did in 2.1.

thatcoder
10 Apr 2009, 3:46 PM
i'm using Ext 2.2 and getting errors whenever i used QuickTips.register.

It'll throw a 'tip' error



Ext.QuickTips.register({
target: this.field.el, // a field element being targetted.
title: 'My Tooltip',
text: 'This tooltip was added in code',
width: 100,
dismissDelay: 20
});

aconran
11 Apr 2009, 6:00 AM
@thatcoder - Please try Ext JS 2.2.1.