In a main.js-File I have the following function
function fireCustomEvent(element, event) {
if (document.createEventObject) {
// dispatch for IE
var evt = document.createEventObject();
return element.fireEvent('on' + event, evt);
}
else {
// dispatch for firefox + others
var evt = document.createEvent("HTMLEvents");
evt.initEvent(event, true, true); // event type,bubbling,cancelable
console.log("dispatch");
return !element.dispatchEvent(evt);
}
}
On one page, this code works just fine, but at another page, I get the "event.dispatchEvent is not a function" - Error. I've read that "jQuery.noConflict()" would do the Job but since i have no jQuery (or any js-Framework) in my project I wonder, how that can be. I've tried it anyway, but then I only get (logically) the "jQuery is not defined" - Error.
Does anyone have an idea?