staticboy
21 Aug 2007, 3:33 AM
Message for jsakalos (http://extjs.com/forum/member.php?u=2178).
Firstly, thank you for the fantastic Accordion extension widget!
However, I think I may have found a tiny bug, but not sure because my JavaScript just isn't good enough to know exactly. I'm trying to dynamically build an accordion (ultimately from JSON received from an XHR). I started out using the 3. Create Accordion with two panels sample code on http://aariadne.com/accordion/, to which I added a third Ext.ux.InfoPanel assigned to variable autopanel1:
var acc = new Ext.ux.Accordion('acc-ct', {
fitHeight: true
})
// create panel 1
var panel1 = acc.add(new Ext.ux.InfoPanel('panel-1', {
}));
// create panel 2
var panel2 = acc.add(new Ext.ux.InfoPanel('panel-2', {
}));
// auto create a panel
var autopanel1 = acc.add(new Ext.ux.InfoPanel(Ext.id(), {
autoCreate:true,
icon: iconPath + 'calendar_view_month.png',
title: '<b>autoCreat</b>ed Title',
content: '<p>Here is some <b>autoCreat</b>ed content!</p>'
}));The result was an Accordion widget with three bars, but the third didn't contain any content. So I started to poke around in the Ext.ux.InfoPanel.js file to see how it worked. I noticed on lines 84-102 the state of autoCreate is handled as follows:
// handle autoCreate
if(this.autoCreate) {
oldHtml = this.el.dom.innerHTML;
this.el.update('');
this.desktop.appendChild(this.el);
this.el.removeClass('x-layout-inactive-content');
}
// handle markup
else {
this.el.clean();
if(this.el.dom.firstChild && !this.bodyEl) {
this.title = this.title || this.el.dom.firstChild.innerHTML;
if(this.el.dom.firstChild.nextSibling) {
this.body = Ext.get(this.el.dom.firstChild.nextSibling);
}
oldTitleEl = this.el.dom.firstChild;
oldTitleEl = oldTitleEl.parentNode.removeChild(oldTitleEl);
oldTitleEl = null;
}
}
It appears that if autoCreate == true then oldHtml = this.el.dom.innerHTML, but for an auto-created InfoPanel el.dom.innerHTML will be "". As oldHtml is used later to set the content then it will be empty regardless of what is set by config.content.
My fix was to comment out line 85 as follow, and it worked for me, but I can't get my head around if this 100% correct!
// handle autoCreate
if(this.autoCreate) {
//oldHtml = this.el.dom.innerHTML;
this.el.update('');
this.desktop.appendChild(this.el);
this.el.removeClass('x-layout-inactive-content');
}
// handle markup
else {
this.el.clean();
if(this.el.dom.firstChild && !this.bodyEl) {
this.title = this.title || this.el.dom.firstChild.innerHTML;
if(this.el.dom.firstChild.nextSibling) {
this.body = Ext.get(this.el.dom.firstChild.nextSibling);
}
oldTitleEl = this.el.dom.firstChild;
oldTitleEl = oldTitleEl.parentNode.removeChild(oldTitleEl);
oldTitleEl = null;
}
}
Firstly, thank you for the fantastic Accordion extension widget!
However, I think I may have found a tiny bug, but not sure because my JavaScript just isn't good enough to know exactly. I'm trying to dynamically build an accordion (ultimately from JSON received from an XHR). I started out using the 3. Create Accordion with two panels sample code on http://aariadne.com/accordion/, to which I added a third Ext.ux.InfoPanel assigned to variable autopanel1:
var acc = new Ext.ux.Accordion('acc-ct', {
fitHeight: true
})
// create panel 1
var panel1 = acc.add(new Ext.ux.InfoPanel('panel-1', {
}));
// create panel 2
var panel2 = acc.add(new Ext.ux.InfoPanel('panel-2', {
}));
// auto create a panel
var autopanel1 = acc.add(new Ext.ux.InfoPanel(Ext.id(), {
autoCreate:true,
icon: iconPath + 'calendar_view_month.png',
title: '<b>autoCreat</b>ed Title',
content: '<p>Here is some <b>autoCreat</b>ed content!</p>'
}));The result was an Accordion widget with three bars, but the third didn't contain any content. So I started to poke around in the Ext.ux.InfoPanel.js file to see how it worked. I noticed on lines 84-102 the state of autoCreate is handled as follows:
// handle autoCreate
if(this.autoCreate) {
oldHtml = this.el.dom.innerHTML;
this.el.update('');
this.desktop.appendChild(this.el);
this.el.removeClass('x-layout-inactive-content');
}
// handle markup
else {
this.el.clean();
if(this.el.dom.firstChild && !this.bodyEl) {
this.title = this.title || this.el.dom.firstChild.innerHTML;
if(this.el.dom.firstChild.nextSibling) {
this.body = Ext.get(this.el.dom.firstChild.nextSibling);
}
oldTitleEl = this.el.dom.firstChild;
oldTitleEl = oldTitleEl.parentNode.removeChild(oldTitleEl);
oldTitleEl = null;
}
}
It appears that if autoCreate == true then oldHtml = this.el.dom.innerHTML, but for an auto-created InfoPanel el.dom.innerHTML will be "". As oldHtml is used later to set the content then it will be empty regardless of what is set by config.content.
My fix was to comment out line 85 as follow, and it worked for me, but I can't get my head around if this 100% correct!
// handle autoCreate
if(this.autoCreate) {
//oldHtml = this.el.dom.innerHTML;
this.el.update('');
this.desktop.appendChild(this.el);
this.el.removeClass('x-layout-inactive-content');
}
// handle markup
else {
this.el.clean();
if(this.el.dom.firstChild && !this.bodyEl) {
this.title = this.title || this.el.dom.firstChild.innerHTML;
if(this.el.dom.firstChild.nextSibling) {
this.body = Ext.get(this.el.dom.firstChild.nextSibling);
}
oldTitleEl = this.el.dom.firstChild;
oldTitleEl = oldTitleEl.parentNode.removeChild(oldTitleEl);
oldTitleEl = null;
}
}