Can't Modify Customevent Data
I need to fire a custom event each time when clicked on div with different data attached. Here is a simplified variant of my code (JSFiddle):
Try:
functionselectItem(id) {
var event_data = {
myid: id
};
if (!arguments.callee.event) arguments.callee.event = newCustomEvent("selectItem");;
arguments.callee.event.data = event_data;
document.dispatchEvent(arguments.callee.event);
}
document.addEventListener("selectItem", function(event) {
console.log(event.data);
});
Or you would need to init the custom Event each time to set the details property like this:
arguments.callee.event.initCustomEvent("selectItem", true, true, event_data);
and details
property will have new updated value each time the event is dispacthed.
Post a Comment for "Can't Modify Customevent Data"