Event Prototypes

I was working for form events and decided to make prototypes for the event handlers. As this is a nice way to code, I wanted share it.

It will be used as:

myform.onChange( function(name, value, isChecked){
    console.log(arguments)
 })

This a tab bit easier for me to remember and easier to read than:

myform.attachEvent("onChange", function(name, value, isChecked){
    console.log(arguments)
 })

Here’s how the prototype is created:

dhtmlXForm.prototype.onChange = function(cb){	
  this.attachEvent("onChange", cb)
}

Here are the events I often use and their prototypes:

dhtmlXForm.prototype.onChange       = function(cb){	this.attachEvent("onChange", cb)}
dhtmlXForm.prototype.onBeforeChange = function(cb){	this.attachEvent("onBeforeChange", cb)}
dhtmlXForm.prototype.onInputChange  = function(cb){	this.attachEvent("onInputChange", cb)}
dhtmlXForm.prototype.onButtonClick  = function(cb){	this.attachEvent("onButtonClick", cb)}