Dispatch event with data

Perhaps you are looking for event.detail new CustomEvent(‘eventName’, {‘detail’: data}) Instead of data use x and in event listener you can access x using event.detail function getSelectionBounds() { var x = (bounds[“x”].toFixed(2)); var y = “xyz”; var selectionFired = new CustomEvent(“selectionFired”, { “detail”: {“x”:x,”y”:y } }); document.dispatchEvent(selectionFired); }; document.addEventListener(“selectionFired”, function (e) { alert(e.detail.x+” “+e.detail.y); });

JavaScript: Listen for attribute change?

You need MutationObserver, Here in snippet I have used setTimeout to simulate modifying attribute var element = document.querySelector(‘#test’); setTimeout(function() { element.setAttribute(‘data-text’, ‘whatever’); }, 5000) var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (mutation.type === “attributes”) { console.log(“attributes changed”) } }); }); observer.observe(element, { attributes: true //configure it to listen to attribute changes }); <div … Read more

Internet Explorer 9, 10 & 11 Event constructor doesn’t work

There’s an IE polyfill for the CustomEvent constructor at MDN. Adding CustomEvent to IE and using that instead works. (function () { if ( typeof window.CustomEvent === “function” ) return false; //If not IE function CustomEvent ( event, params ) { params = params || { bubbles: false, cancelable: false, detail: undefined }; var evt … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)