I'm trying to make a controller for my app. I'm not able to do what I want and I don't understand why :-( I'm not a javascript expert so probably I'm doing something that is not allowed. Error from firebug:
TypeError: window[("Controller." + where)] is not a function
The error is clear, but why is this happening?
jsFiddle: http://jsfiddle.net/TB8yr/1/
var Controller= function(){
this.currentpage='home';
}
Controller.prototype.route=function(where){
window["Controller."+where]();
};
Controller.prototype.goHome=function(){
alert('route gohome');
}
Controller.prototype.goBack=function(){
alert('route goback');
}
//////
test=new Controller();
test.route('goHome');