Skip to content

Instantly share code, notes, and snippets.

@matugm
Created July 14, 2015 02:10
Show Gist options
  • Save matugm/be30a3eeaeded0d8dad2 to your computer and use it in GitHub Desktop.
Save matugm/be30a3eeaeded0d8dad2 to your computer and use it in GitHub Desktop.
javascript refactor
// Old
$(function() {
var flashCallback;
flashCallback = function() {
return $(".alert").fadeOut();
};
$(".flash-message").bind('click', (function(_this) {
return function(ev) {
return $(".alert").fadeOut();
};
})(this));
return setTimeout(flashCallback, 2000);
});
// New
$(function() {
var flashCallback;
flashCallback = function() {
return $(".alert").fadeOut();
};
$(".flash-message").on('click', flashCallback);
return setTimeout(flashCallback, 2000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment