I want to make an extension method to jQuery so that it instead of looking like this:
$(document).on('click', '#myElement', function(e){
doSomething(e);
});
looks like this:
$('#myElement').onClick(function(e) {
doSomething(e);
})
This is because I want to be able to go the definition of '#myElement' when I click F12 in VS (I have the script file in a different folder).
I've tried with:
(function( $ ) {
$.fn.onClick= function(callback) {
if(callback)
{
$(document).on('click', $(this).attr('id'), callback.call(this));
}
});
})( jQuery );
But it doesn't seem to bind.