K
Kidogg
Hi all,
First let me apologize for being an idiot when it comes to Javascript,
I've only recently had to do any serious work in it - and I'm properly
stuck already!
Essentially I'm trying to bind a click event (using MooTools) to a
<div>, but inside the event handler have access to an object (of my
own creation) that "owns" the <div>. So essentially something like the
following (syntax is probably wrong - I'm away from my dev machine):
function MyObject(objid,parent)
{
this.parent = $(parent);
this.divhandle = new Element('div');
this.divhandle.injectInside(this.parent);
this.objid = objid;
this.divhandle.addEvent('click', this._handleClick);
}
MyObject.prototype._handleclick = function(ev)
{
var e = new Event(e);
// how can i get a reference to the "MyObject" instance here?
// this.? doesnt seem to be valid & e.target just references the
<div>
}
Any help / comments appreciated,
Thanks,
Kieran
First let me apologize for being an idiot when it comes to Javascript,
I've only recently had to do any serious work in it - and I'm properly
stuck already!
Essentially I'm trying to bind a click event (using MooTools) to a
<div>, but inside the event handler have access to an object (of my
own creation) that "owns" the <div>. So essentially something like the
following (syntax is probably wrong - I'm away from my dev machine):
function MyObject(objid,parent)
{
this.parent = $(parent);
this.divhandle = new Element('div');
this.divhandle.injectInside(this.parent);
this.objid = objid;
this.divhandle.addEvent('click', this._handleClick);
}
MyObject.prototype._handleclick = function(ev)
{
var e = new Event(e);
// how can i get a reference to the "MyObject" instance here?
// this.? doesnt seem to be valid & e.target just references the
<div>
}
Any help / comments appreciated,
Thanks,
Kieran