You will have to create an object first and then call the method:
var Dashboard=function(){
this.__construct=function(){
console.log('Dashboard is Created');
template=new Template();
events=new Event();
load_todo();
//console.log(Template.todo({todo_id:1,content:"This is life"}));
};
//-----------------------------------
var load_todo=function(){
console.log('load todo is called');
$.get("api/get_todo",function(o){
$("#list_todo").html();
},'json');
};};
//You have to call the construct function
var dashboard = new Dashboard().__construct();
Now if you want to keep your functions private then you can do something like the following example:
function Dashboard(){//begin dashboard constructor
__construct();
function __construct(){
console.log('Dashboard is Created');
template=new Template();
events=new Event();
load_todo();
//console.log(Template.todo({todo_id:1,content:"This is life"}));
}
function load_todo(){
console.log('load todo is called');
$.get("api/get_todo",function(o){
$("#list_todo").html();
},'json');
}
}//end dashboard constructor
//create a new Dashboard object instance
var dashboard = new Dashboard();
//This will not work because load_todo will be undefined.
console.log(dashboard.load_todo());
__construct, do you call it before you initialise theload_todovariable?varfor yourtemplateandeventsvariables.load_todobefore yourDashboard.