CableDawg
14 Aug 2008, 3:53 AM
I have a QuickTip that I have initialized to be 100px tall. Before I display the QuickTip, I resize it to match the width of a particular element on the page.
notesQtip.setWidth(btn.getEl().parent('.x-box-mc').getWidth(true));
Doing so causes the following code to execute in BoxComponent:
setSize : function(w, h){
// support for standard size objects
if(typeof w == 'object'){
h = w.height;
w = w.width;
}
// not rendered
if(!this.boxReady){
this.width = w;
this.height = h;
return this;
}
**SNIP**
setWidth : function(width){
return this.setSize(width);
}
As you can see, setWidth calls setSize with only one argument. When setSize is run and the box is not yet rendered, it resets the height of the BoxComponent instance to the value of the second argument (height) which in this case is undefined.
setHeight has a similar issue:
setHeight : function(height){
return this.setSize(undefined, height);
}
Calling setHeight will result in the width of the element getting set to undefined (again, only if the element is not yet rendered).
A possible fix could be:
setWidth : function(width){
return this.setSize(width, this.height);
},
setHeight : function(height){
return this.setSize(this.width, height);
},
This way, the currently configured width/height value is simply passed along so it can never get changed to undefined unless you specifically call setSize with the wrong parameters.
The downside to this is that it may trigger the block of code marked with the comment "this code is nasty but performs better with floaters" which involves defering the heigh calculation and resize event firing when the element HAS been rendered.
Another possible fix is:
// not rendered
if(!this.boxReady){
this.width = w || this.width;
this.height = h || this.height;
return this;
}
Pretty self-explanatory modification. Just default to the current width/height if the passed in width/height value evaluates to false.
Sorry if this is a dupe. I searched the forums but did not find anything.
notesQtip.setWidth(btn.getEl().parent('.x-box-mc').getWidth(true));
Doing so causes the following code to execute in BoxComponent:
setSize : function(w, h){
// support for standard size objects
if(typeof w == 'object'){
h = w.height;
w = w.width;
}
// not rendered
if(!this.boxReady){
this.width = w;
this.height = h;
return this;
}
**SNIP**
setWidth : function(width){
return this.setSize(width);
}
As you can see, setWidth calls setSize with only one argument. When setSize is run and the box is not yet rendered, it resets the height of the BoxComponent instance to the value of the second argument (height) which in this case is undefined.
setHeight has a similar issue:
setHeight : function(height){
return this.setSize(undefined, height);
}
Calling setHeight will result in the width of the element getting set to undefined (again, only if the element is not yet rendered).
A possible fix could be:
setWidth : function(width){
return this.setSize(width, this.height);
},
setHeight : function(height){
return this.setSize(this.width, height);
},
This way, the currently configured width/height value is simply passed along so it can never get changed to undefined unless you specifically call setSize with the wrong parameters.
The downside to this is that it may trigger the block of code marked with the comment "this code is nasty but performs better with floaters" which involves defering the heigh calculation and resize event firing when the element HAS been rendered.
Another possible fix is:
// not rendered
if(!this.boxReady){
this.width = w || this.width;
this.height = h || this.height;
return this;
}
Pretty self-explanatory modification. Just default to the current width/height if the passed in width/height value evaluates to false.
Sorry if this is a dupe. I searched the forums but did not find anything.