Passing a variable (object) to the .on() function
I'm trying to bind an event handler for certain elements; past, present, and future (like the deprecated .live() function).
I understand I can do this:
- $(document).on('click', 'input.clickable', function(){
- // blah blah
- });
Where 'input.clickable' is a selector string. I'd like to be able to pass in an actual jQuery object instead, like this:
- var fancy_input = $(something).find('input.clickable');
- $(document).on('click', fancy_input, function(){
- // bloo blah blah
- });
It looks like that's not possible. The next best thing I can think of is using a variable that just contains the selector string, and passing
that in. Does anyone have a better idea?