i am a bit embarassed to ask this, but i do this so much i have to ask. Occasionally, i need to pass/handle custom events on the fly. Rather than creating a whole custom event class, i will just do something like
but what if i want to pass some more info with that custom event...do i have to make it a public variable of myObject? For example, if myObject is storing a number and i want to fire off with the event, and only pass that variable, is there a way to do something like:Code:myObject.dispatchEvent(new Event('thisCustomEvent')); //and then handle it later myObject.addEventListener('thisCustomEvent',doSomething);
as you guess, i get an errorCode:myObject.dispatchEvent(new Event('thisCustomEvent',customNumberProperty));




Reply With Quote