I’m trying to get rid of that nasty variable declaration of ref in this instance, I’m sure there is a way to get out of the each scope to get the “this” of the on-call. I just have no idea how to.
$(document).on('click', '.item', function(){
var ref = $(this).attr('data-id');
$.each(t, function(){
if(this.id == ref){
//action
return false;
}
});
}
This isn’t really life or death, I just am trying to clean up code.
There is a way to do this: use the
eventreference passed to the event handler automatically.But, that doesn’t buy you anything except more time to do other things while the code runs. 😉