HighDots Forums  

Attach a class method to event handler

Javascript (Italian) Il linguaggio JavaScript (it.comp.lang.javascript)


Discuss Attach a class method to event handler in the Javascript (Italian) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Ugo
 
Posts: n/a

Default Attach a class method to event handler - 05-29-2008 , 10:34 AM






Hi guys,

until now I make so:

[html]
<div id="my_div"><!-- content --></div>

[simple-js]
MyClass.prototype.doSomething = function( ) {};
MyClass.prototype.assignFun = function( )
{
var selfObj = this;
document.getElementById('my_div').onclick = function ( e )
{
selfObj.doSomethingWith( e || event );
}
}

How do I avoid the closure of my object reference?
And MyClass is not a Singleton...

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.