Created
September 29, 2014 20:13
-
-
Save boertel/5800df36be1cf902722d to your computer and use it in GitHub Desktop.
toggle
This file contains hidden or 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
(function ($) { | |
$.fn.toggle = function (options) { | |
var settings = $.extend({}, options); | |
$(this).hide(); | |
return this.each(function () { | |
var $node = $(this), | |
id = $node.data('action'), | |
state = $node.data('state'), | |
eventName = 'toggle:' + state; | |
$node.on(eventName, function () { | |
$('[data-action=' + id + ']').hide(); | |
$node.show(); | |
}); | |
}); | |
} | |
}(jQuery)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment