I'm getting a "Cannot read property of undefined" error in the following code.
What happens is that the initFromServer() is called which goes to get the model from the server. But what ends up happening is that when init() is called, the parameter model is undefined. Using console.log to determine what is going on it seems that it never reaches the Proxy.getModel() function before it determines that model is undefined.
I'm not entirely sure what is going on. There are a lot of other functions and what not that I have not inserted. Hopefully it makes sense.
ClientModel.prototype.initFromServer = function(success) {
this.getProxy().getModel(this.init(), success());
}
ClientModel.prototype.init = function(model) {
this.setMap(new catan.models.Map(model.map.radius));
};
In the proxy file we have:
Proxy.prototype.getModel = function(update, success) {
jQuery.get("/game/model", function(data) {
update(data);
success(data);
});
};
init()method with 1 argument and don't pass any when you invoke it.