I've just created a method that toggles menu visibility. At the moment I've gone with an if
..else
which checks my flag and acts appropriately. Can anyone offer any suggestions on how to make this snippet better? Maybe it shouldn't all live in the same snippet? Maybe I should be combining the show/hide logic that's duplicated in the if
..else
?
onNavTriggerClick: function(event) {
var $currentTarget = $(event.currentTarget);
if(this._navOpen) {
Backbone.Events.trigger('hide:menu');
$currentTarget.removeClass('is-active');
this._navOpen = false;
} else {
Backbone.Events.trigger('show:menu');
$currentTarget.addClass('is-active');
this._navOpen = true;
}
}