class methods eventuality handlers javascript?


is there best-practice common proceed javascript have category members eventuality handlers?



consider following rudimentary example:



<head>
<script language="javascript" type="text/javascript">

clickcounter = function(buttonid) {
this._clickcount = 0;
document.getelementbyid(buttonid).onclick = this.buttonclicked;
}

clickcounter.prototype = {
buttonclicked: function() {
this._clickcount++;
alert('the symbol clicked ' + this._clickcount + ' times');
}
}

</script>
</head>
<body>
<input type="button" id="btn1" value="click me" />
<script language="javascript" type="text/javascript">
var btn1counter = new clickcounter('btn1');
</script>
</body>


the eventuality handler buttonclicked gets called, nonetheless _clickcount member inaccessible, this points object.



any good tips/articles/resources kind problems?



Comments

Popular posts from this blog

list macos calm editors formula editors

how hibernate @any-related annotations?

why does floated <input> control floated component slip over too distant right ie7, nonetheless firefox?