I'm using hammer.js for a touch menu for a site, and getting:
"Object doesn't support property or method 'addEventListener'" hammer.js, line 247 character 13
with IE8.
The actual code from hammer.js that is not working:
/**
* simple addEventListener
* @param {HTMLElement} element
* @param {String} type
* @param {Function} handler
*/
bindDom: function(element, type, handler) {
var types = type.split(' ');
for(var t=0; t<types.length; t++) {
element.addEventListener(types[t], handler, false);
}
},
Any idea how I can fix this?
Jquery used to have a similar issue: http://bugs.jquery.com/ticket/11127
Starting from here: addEventListener not working in IE8
You can fix the code function by checking the definition of addEventListener
like :
bindDom: function (element, type, handler) {
var types = type.split(' ');
for (var t = 0; t < types.length; t++) {
if (!element.addEventListener) {
element.attachEvent(types[t], handler);
} else {
element.addEventListener(types[t], handler, false);
}
}
},
if it works we can eventually pull a request to the developers.