I have a holder object where I insert Class instances.
var instances = {};
$.each(response.data, function(index, value) {
instances[value.platform.toLowerCase()] = new FetcherClass(value.platform, value.type, value.tempo, value.max);
});
value.platform is the name of the new instance.
All seems to works fine, but when I want to call a function within an instance, allways fires the function of the last instance.
For example:
instances.name1.start();
In case there are 'name1', 'name2' and 'name3' instances, the start() function fired belongs to 'name3' instance.
Here I post the output in console of Object 'instances'.
Object name1 : FetcherClass nam2 : FetcherClass name3 : FetcherClass name4 : FetcherClass name5 : FetcherClass name6 : FetcherClass name7 : FetcherClass name8 : FetcherClass name9 : FetcherClass name10 : FetcherClass proto : Object
A link to an example: JSFiddle
What's wrong?
FetcherClassandstartandresponse.data? - Oriol