View Full Version : adding dynamically to object lists..

4 Feb 2008, 11:16 AM
Hey Ext'ers,

I have an object list:

var modules = [
new objectBuild('static1'),
new object2(),
new object3(),
new object4(),
new object5()

After I declare modules, I want to dynamically add lists from metadata I store in a global variable:

Ext.each(myGlobalMetaData, function(item, index){
// modules.add(item.cfg) ???

I don't know how to properly append to a object list. How do I do accomplish this? Is there another way?

4 Feb 2008, 11:24 AM
since "modules" is an array, you can just "push" an element on the array.

modules.push("some new object")

The "push" method on the Array object will append the object to the end of the array.

4 Feb 2008, 11:40 AM
Thanks, that works great. Shoulda known it was that simple!