As of jQuery 1.8, the .toggle() utility function is deprecated, and I'm looking across SO to no avail for a quickie snippet to mimic its functionality. I looked at a proposed solution here but I find it too verbose.
I wonder if i should toggle a custom class name and do an .on() / .off(), or if I should track a boolean value?
In my mind I'm thinking I should be able to do it all in a single .on() event map...
Has anyone here done it before and can share a snippet?
EDIT
I must say, it's a bit irritating when people down vote questions so aggressively. Yes, some similar snippets are on SO but the question here is about minimizing the code. The old jQuery .toggle() was a nice easy way, and i just was looking for some pointers about the best approach.
What I came up with is this: anyone have ideas how to avoid using a global variable to track my click state?
g.toggler = 0;
$(document).on({
click : function(){
g.toggler++;
if(g.toggler%2==1){
console.log('forth');
} else {
console.log('back');
};
}
});