This is a common js dilemma in js when accessing methods from other
methods. Where "this" points depends on where and how it is called.

Try:

function MainPage(){
  var that = this;                        // Add this line
  this.init = function(){
    $('#sample').click(function(){
      // here is my problem, inside this anonymous function how can I
access the method_one function?
      that.method_one(param_1, param_2);              // Modify this
line
    });
  }
  this.method_one = function(param_1, param_2){
    $(param_1).load(param_2);
  }

}

Reply via email to