Reputation: 11296
I have an included javascript file thats initializes an empty array object called "widgets"
var Widgets = {};
function Widget(a,b,c){
this.a = a;
...
}
in the same include a bunch of function prototypes are defined to add widget info to a widget:
Widget.prototype.addWidgetInfo(a,b,c){
this.info.a = a;
this.info.b = b;
...
}
there are also a number of functions that support a document.ready(){ } block in the end of the file.
in the body of the page, for each widget outputted a line of js is outputted as well calling this prototype function
Widgets[id] = new Widget();
Widgets[id].addwidgetInfo("bla","bla","bla");
When document ready calls however
Widgets[id].info is an empty array....
I can't figure out why on earth this data is not available! please help
Upvotes: 0
Views: 299
Reputation: 3254
There are a few errors in the example given. I'm not sure if they are your problem, or just a problem in your example:
addWidgetInfo
isn't being declared correctly. Should be:
Widget.prototype.addWidgetInfo = function(a,b,c){
this.info
isn't initialized. Should be
Widget.prototype.addWidgetInfo = function(a,b,c){
this.info = {};
this.info.a = a;
...
}
Upvotes: 2