Created
September 24, 2014 08:51
-
-
Save maier-stefan/41d2634aa023ca074da0 to your computer and use it in GitHub Desktop.
Checkbox trigger
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
$('.radio-skin, .checkbox-skin').on('click', function(event){ | |
event.preventDefault(); | |
var $label = $(this), | |
$input = $label.find('input'); | |
if ($input.attr('checked')) { | |
$label.removeClass('on').addClass('off'); | |
$input.removeAttr('checked'); | |
$input.attr('value', '0'); | |
if ($label.has('[data-toggle]')) { | |
$($label.data('toggle')).addClass('hidden').removeClass('visible'); | |
} | |
} else { | |
$label.removeClass('off').addClass('on'); | |
$input.attr('checked', 'checked'); | |
$input.attr('value', '1'); | |
if ($label.has('[data-toggle]')) { | |
$($label.data('toggle')).removeClass('hidden').addClass('visible'); | |
} | |
if (typeof $input.attr('checked_value') !== typeof undefined && $input.attr('checked_value') !== false) { | |
$input.val($input.attr('checked_value')); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment