I’m working with some event handlers, and am getting a bit confused as to one aspect.
According to this thread, Firefox adheres to WC3 standards and passes click events as a parameter to your handler. You can then access this event by coding MyHandler(event). However, what if you’re passing another parameter already?
Specifically, my onClick function is editItem(this) where this refers to the table row that was clicked. However, I need to call event.stopPropagation() inside the editItem function in order to prevent some other handlers from going off. In IE and Chrome, this works, but in Firefox, event.stopPropagation() gives me a null pointer, which makes sense because I’m not taking in an event parameter into editItem(this).
My question is, how do I take in both this and event in my onClick function? Can I just append them like editItem(this, event)? How will Firefox know which one is the event and which one is my personal parameter?
You can do
editItem(this, event)as you mentioned. Then your function just needs to be defined like this:It will know which parameter is which because of the order of the parameters.