In this example, which is great, the internal checkbox (and radiobutton) state remains the same.
The expected behavior, is that when I click the button, the inner checkbox gets checked or not accordingly.
I'm looking at the toggle function followed below on bootstrap and I see this is implemented, so why doesn't this work on the bootstrap example page (and in my website)?
Button.prototype.toggle = function () {
var changed = true
var $parent = this.$element.closest('[data-toggle="buttons"]')
if ($parent.length) {
var $input = this.$element.find('input')
if ($input.prop('type') == 'radio') {
if ($input.prop('checked') && this.$element.hasClass('active')) changed = false
else $parent.find('.active').removeClass('active')
}
if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
} else {
this.$element.attr('aria-pressed', !this.$element.hasClass('active'))
}
if (changed) this.$element.toggleClass('active')
}
Aucun commentaire:
Enregistrer un commentaire