Calling method from inside Javascript constructor -
i'm trying call method inside javascript contructor. here's example:
function team(team_id) { this.team_id = team_id; init(); this.init = function () { alert('testing out: ' + this.team_id); }; } var my_team = new team(15); also: http://jsfiddle.net/n8rxt/2/
this doesn't work. alert never displayed. ideas? thanks.
you need place call init() method, underneath definition.
also call using this.init();
function team(team_id) { this.team_id = team_id; this.init = function () { alert('testing out: ' + this.team_id); }; this.init(); } var my_team = new team(15);
Comments
Post a Comment