I am trying to refer to the event type here, I can refer to the element however. FIDDLE
var app = {
open : function(el) {
//Want to run this.. dont know how to refer to event properly
if(jQuery(e.target).is('.cantOpen')){
e.preventDefault();
return;
}
jQuery(el).toggleClass('opened')
},
}
jQuery(document).ready(function() {
//Prefer this
jQuery('.main').click(function(e) {
e.preventDefault();
app.open(this)
});
//Ideally I dont want to add the code inside here but this does work
jQuery('.main').click(function(e) {
e.preventDefault();
if(jQuery(e.target).is('.cantOpen')){
e.preventDefault();
return;
}
app.open(this)
});
});
Hopefully you see my angle here... I would like to learn how to refer to the event type inside my open function? Is it possible? FIDDLE
app.open(this, e)and define.opento accept a second argument..maine.targetand in anotherelfor the same thing. Be consistent, the references toelcan be removed entirely and then you would call the function asapp.open(e).jQuery(el).toggleClass('opened')