Skip to content

Commit

Permalink
Fix minhur#23 - Restores label basic functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
ramaroberto committed Aug 8, 2015
1 parent 8c21c66 commit 0d165ce
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions js/bootstrap-toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,17 @@
}

Toggle.prototype.defaults = function() {
if (this.$element.parent().prop('tagName') == 'LABEL') {
this.$element.parent().click( function(e) {
if (!$(e.toElement).hasClass('toggle-off') &&
!$(e.toElement).hasClass('toggle-on')) {
var $checkbox = $(this)
.find('input[type=checkbox][data-toggle^=toggle]').first()
$checkbox.bootstrapToggle('toggle')
e.preventDefault()
}
})
}
return {
on: this.$element.attr('data-on') || Toggle.DEFAULTS.on,
off: this.$element.attr('data-off') || Toggle.DEFAULTS.off,
Expand Down

0 comments on commit 0d165ce

Please sign in to comment.