Skip to content

Instantly share code, notes, and snippets.

@boertel
Created September 29, 2014 20:13
Show Gist options
  • Save boertel/5800df36be1cf902722d to your computer and use it in GitHub Desktop.
Save boertel/5800df36be1cf902722d to your computer and use it in GitHub Desktop.
toggle
(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