I’ve got a javascript ‘class’ which has two methods. In one of the methods, I’m trying to create a flot plothover binding which has access to the properties and methods of my class where the binding is made. What I’m trying to figure out is how to access the class properties and methods from within the bound function.
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
}
}
}
Obviously, I can’t use ‘this’ to see MyClass – so is it possible to access and invoke MyClass’ properties and methods from within the bind function?
I could have multiple clones of MyClass running around, so whatever I need to do has to be isolated in each cloned class.
Thanks for any advice.
Corey.
You can create a reference to
this: