javascript从flot绑定函数访问类对象

javascript从flot绑定函数访问类对象,javascript,flot,Javascript,Flot,我有一个javascript“类”,它有两个方法。在其中一个方法中,我尝试创建一个flot plothover绑定,该绑定可以访问创建绑定的类的属性和方法。我想弄清楚的是如何从绑定函数中访问类属性和方法 var MyClass = { Property1 = null, ShowToolTip: function( x, y, text ) { ...stuff... }, Render: function ( arg1, arg2 ) { this.Propert

我有一个javascript“类”,它有两个方法。在其中一个方法中,我尝试创建一个flot plothover绑定,该绑定可以访问创建绑定的类的属性和方法。我想弄清楚的是如何从绑定函数中访问类属性和方法

var MyClass = 
{
  Property1 = null,
  ShowToolTip: function( x, y, text ) { ...stuff... },
  Render: function ( arg1, arg2 ) 
  {
     this.Property1 = "this works";
     $('#placeholder').bind('plothover', function (event, pos, item ) {
        this.Property1 = "non workie";         // need access to Property1
        this.ShowToolTip( 10, 10, "stuff" );   // need access to ShowToolTip
     }
  }
}
显然,我不能使用“this”来查看MyClass——那么是否可以从bind函数中访问和调用MyClass的属性和方法呢

我可以有多个MyClass的克隆运行,所以我需要做的任何事情都必须在每个克隆的类中隔离

谢谢你的建议。
Corey.

您可以创建对该的引用:

Render: function ( arg1, arg2 ) 
      {
         this.Property1 = "this works";
         var that = this;
         $('#placeholder').bind('plothover', function (event, pos, item ) {
            that.Property1 = "non workie";         // need access to Property1
            that.ShowToolTip( 10, 10, "stuff" );   // need access to ShowToolTip
         }
      }

您可以创建对该的引用:

Render: function ( arg1, arg2 ) 
      {
         this.Property1 = "this works";
         var that = this;
         $('#placeholder').bind('plothover', function (event, pos, item ) {
            that.Property1 = "non workie";         // need access to Property1
            that.ShowToolTip( 10, 10, "stuff" );   // need access to ShowToolTip
         }
      }