Skip to content

Instantly share code, notes, and snippets.

@Azerothian
Created February 23, 2016 01:35
Show Gist options
  • Save Azerothian/5ae38ad8f753c2020049 to your computer and use it in GitHub Desktop.
Save Azerothian/5ae38ad8f753c2020049 to your computer and use it in GitHub Desktop.
Even in the world of jQuery... promises rain supreme.. even if its a bastardized.
$(".feature-tab-header").on("click", function() {
var targetTab = "." + $(this).attr("id");
var targetHeader = this;
var promises = [
$(".feature-tab.active").removeClass("active").promise(),
$(".feature-tab-header").removeClass("active").promise()
];
return $.when(promises).done(function() {
$(targetHeader).addClass("active");
$(targetTab).addClass("active");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment