WebFX WebBoard
Message Thread:
View All Messages
Back to WebFX
 xmenu: toObject() function, Arnaud, August 1, 2003
     Re:xmenu: toObject() function, Erik Arvidsson, August 5, 2003

Subject: Re:xmenu: toObject() function From: Erik Arvidsson Date: August 5, 2003
The inner loop is for creating the sub menus. The elements for these are not children but siblings. Therefore you should return a document fragment instead of an element.

var df = document.createDocumentFragment();
df.appendChild( menuElement );
loop over subs
df.appendChild( subElement)
return df;

And as a side note... Your usage of createElement is incorrect. The argument is the tagName and nothing else. This is a known bug/feature in IE5+



Hi Erik,
I want to had a toObject() function to get an object instead of a string.
WebFXMenuBar.prototype.toObject = function () {
var str = "<div id='" + this.id + "' class='webfx-menu-bar'></div>";
var obj = document.createElement(str);
str = "";
// loop through all menuButtons
for (var i = 0; i < this._menuItems.length; i++)
str += this._menuItems[i];
obj.innerHTML = str;
return obj;
But I missed a point: in your toString function there's a second loop,
for (var i = 0; i < this._subMenus.length; i++)
str += this._subMenus[i];

and I don't understand the meaning of the subMenus for the MenuBar object.
Could you please explain?


Enter your reply to this message below. HTML tags are not supported but words that start with http://, ftp:// or mailto: are converted to links.

View All Messages
Back to WebFX