I have a form that gets loaded through an ajax call, which means I need to use event delegation
in order to detect when a select box in the form gets clicked.
My code looks like the following snippet below:
$( document ).on( "click", "form select", selectFunction );
However, in addition to utilizing event delegation
, I'd also like to be able to pass custom event.data
to the on
handler function.
So, I'd like to have my code snippet look like below...
$( document ).on( "click", "form select", { foo: 'bar' }, selectFunction );
...and my handler function would act like something like this.
function selectFunction( event ) {
console.log(event.data.foo); // outputs 'bar'
}
Unfortunately, event.data
returns undefined
.
Thank you for any and all help.