I am using icefaces and the input mask sometimes the script that creates an input mask runs twice. I want to remove any previous input masks on a given element.
what is the best way to accomplish this?
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have been successfull removing eventlisteners from firefox and chrome but ie I still can't get to work correctly.
I added a new function to JavaScriptUtils.js
I am using icefaces and the input mask sometimes the script that creates an input mask runs twice. I want to remove any previous input masks on a given element.
what is the best way to accomplish this?
Thanks
I have been successfull removing eventlisteners from firefox and chrome but ie I still can't get to work correctly.
I added a new function to JavaScriptUtils.js
function removeObserver(object,eventName,handler){
object=getObject(object);
if(object!=null){
if(object.removeEventListener){
object.removeEventListener(eventName,handler,false);
} else if(object.detachEvent){
object.detachEvent("on"+eventName,function(){
return invokeAsMethod(object,handler,)
})
} else {
object=null;
}
}
}
as well as adding function to InputMask.js
this.disable=function(){
removeObserver(this.control,"blur",onBlur);
removeObserver(this.control,"focus",onFocus);
removeObserver(this.control,"keyup",onKeyUp);
removeObserver(this.control,"keypress",onKeyPress);
removeObserver(this.control,"keydown",onKeyDown);
}
No luck with IE though any help would be greatly appreciated!
It's possible that event names in IE are case-sensitive. Therefore onblur <> onBlur. Check this out.
Another option is to look at the YUI library, it has a good support of event listeners, perhaps you can copy some code snippet from there.