Registering events within an object
I'm having a hard time figuring out how to refer to an object while inside a jquery event function. In the following example, "this" at first is referenced as #myDiv. But inside the draggable event, "this" refers to something else. I am not sure what it is referring to, but how do I reference the original object (Human) from within this event?
- var Person = new Human("#myDiv", "my data");
- function Human(element, myName) {
- this.name = myName;
- $(element).draggable({
- start: function() { alert(this.name); }
- });
- }