/*
Basically I'm trying the pass an array of objects and pass them into
the Test class, but it only seems to be passing in the last object in
the array...
*/


// class to store the id, first, last name
Test = Class.create({
        options:{},
        initialize:function(count,obj){
                this.options.id = count;
                this.options.first = obj.first;
                this.options.last = obj.last;
        }
});

// the array of the first and last name items
people = [{first:"Santa",last:"Claus"},
                  {first:"John",last:"Doe"},
                  {first:"Jane",last:"Johnson"}];

// displaying the items to FF console,
// open your console and click on the object and hit options to see
the parameters
Start ={
        init:function(people){
                people.each(function(obj,count){
                        //this shows looping through the array correctly
                        Start.log(obj);
                        //in theory this should be showing the class with each 
array item
instead it s storing the last item
                        Start.log(new Test(count,obj));
                });
        },
        log:function(message){
                if(window.console && console.log) console.log(message);
        }
};

Start.init(people);


/*
console will show something like this

Object { first="steven",  more...}
Object { options=Object}   <------ click these, notice they dont match
the object above instead show last item
Object { first="John", more...}
Object { options=Object}  <------ click these, notice they dont match
the object above instead show last item
Object { first="Jane", more...}
Object { options=Object}  <------ click these, notice they dont match
the object above instead show last item

Can someone tell me whats wrong here, thanks
*/

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to