Last active
September 29, 2017 08:17
-
-
Save ghabxph/ed4c14fe6b2a45737fb7fa2b5c947114 to your computer and use it in GitHub Desktop.
General purpose toggler
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
/** | |
* Toggler | |
* @author Gabriel Lucernas Pascual <me@ghabpxh.info> | |
* @license MIT | |
* @link https://gist.github.com/ghabxph/ed4c14fe6b2a45737fb7fa2b5c947114 | |
*/ | |
$(function(){ | |
/** | |
* Waits for .toggler element to be clicked | |
*/ | |
$('.toggleable').click(function(){ | |
var sState = (iState === 'toggle-off') ? 'toggle-on' : 'toggle-off'; | |
this.attr('data-state', sState); | |
this.trigger(sState); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment