Created
January 29, 2015 04:45
-
-
Save crongro/62a7b2d64895268dbd4d to your computer and use it in GitHub Desktop.
attach Events using 'handlEvent'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function TA() { | |
this.ele = document.querySelector("#message"); | |
this._attachEvents(); | |
} | |
TA.prototype = { | |
_handlers : { | |
click : '_clickHandler', | |
mousedown : '_mousedownHandler', /* test */ | |
touchstart: '_touchHandler',/* test */ | |
keyup : '_keyHandler',/* test */ | |
}, | |
_attachEvents : function() { | |
this.ele.addEventListener('click', this, false); | |
}, | |
handleEvent : function(e) { | |
console.log("handleEvent called : ", e.type); | |
var fpHandler = this[this._handlers[e.type]]; | |
fpHandler.call(this, e); | |
}, | |
_clickHandler : function(e) { | |
console.log("clicked!!!", e.type); | |
} | |
}; | |
var ta = new TA(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment