Accessing a Javascript prototype function -


i have prototype function such event.

prototype

func("input_element_id").event("keyup",function(){     alert("works on keyup in input!"); }  func.prototype= {     keyup: function(func){          //adding event listener , callback using func     },     event: function(e,func) {          //what here call function "keyup"     } }; 

the prototype name in variable e. how can call function using variable name?

i doing this, passing "keyup keydown" add keyup , keydown listeners, better calling each prototype function individually.

thanks.

var func = function(element){   this.element = element; };  func.prototype = {     keyup: function(handler){       this.element.onkeyup = handler;     },     event: function(e,handler){         switch(e){             case 'keyup':               return this.keyup(handler);             break;         }     } } 

http://jsfiddle.net/ydekw/


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -