I'm calling an anonymous function:
closeSidebar(function() {
alert("function called");
$(this).addClass("current");
setTimeout(function(){openSidebar()}, 300);
});
But $(this) doesn't work as expected and I need to pass it as an argument into the function. After a bit of research I thought this would work:
closeSidebar(function(el) {
$(el).addClass("current");
setTimeout(function(){openSidebar()}, 300);
})(this);
But it doesn't. How do I add arguments to an anonymous function?
jsFiddle - Click a button on the right, it animates in then calls the function above. When the button has the class "current" it will have a white bar on the left side of the button but the class never changes.