Created
November 3, 2011 20:30
-
-
Save Wolfr/1337697 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jwerty.key('←', function () { | |
// Check if we are on the first slide, if so, do not execute | |
if (!$('.introSlide').is(":visible")) { | |
prevSlide(); | |
buttonToggle(); | |
}; | |
}); | |
$('#prevSlide').click(function() { | |
// Check if we are on the first slide, if so, do not execute | |
if (!$('.introSlide').is(":visible")) { | |
prevSlide(); | |
buttonToggle(); | |
}; | |
}); |
jwerty.key('↑', function () {
resetSlides();
});
$('.resetSlides').click(function() {
resetSlides();
});
Could be just…
jwerty.key('↑', resetSlides);
$('.resetSlides').click(resetSlides);
But actually you don’t need a named function at all:
var $resetSlides = $('.resetSlides');
$resetSlides.click(function() {
// teh coads
});
jwerty.key('↑', $resetSlides.click); // i.e. just trigger a `click` event on `$resetSlides`
Hmm yeah, that makes sense. Your 2nd code block is more readable and I can keep all my functions apart so went for that. The 3rd code block is more 1337 I guess ;)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So we can remove the anonymous functions say eising
Example:
How?
(NM you were faster :))