Created
December 28, 2013 10:08
-
-
Save Arsey/8157974 to your computer and use it in GitHub Desktop.
modified to support group choosing createOptionValue function from bootstrap-multiselects by David Stutz(https://github.com/davidstutz/bootstrap-multiselect)
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
// Will build an dropdown element for the given option. | |
createOptionValue : function(element,groupId) { | |
if ($(element).is(':selected')) { | |
$(element).attr('selected', 'selected').prop('selected', true); | |
} | |
// Support the label attribute on options. | |
var label = $(element).attr('label') || $(element).text(); | |
var value = $(element).val(); | |
var inputType = this.options.multiple ? "checkbox" : "radio"; | |
var $li = $('<li><a href="javascript:void(0);"><label class="' + inputType + '"><input type="' + inputType + '" /></label></a></li>'); | |
var selected = $(element).prop('selected') || false; | |
var $checkbox = $('input', $li); | |
$checkbox.val(value); | |
$checkbox.attr('data-group-id',groupId); | |
if (value == this.options.selectAllValue) { | |
$checkbox.parent().parent().addClass('multiselect-all'); | |
} | |
$('label', $li).append(" " + label); | |
$('.multiselect-container', this.$container).append($li); | |
if ($(element).is(':disabled')) { | |
$checkbox.attr('disabled', 'disabled').prop('disabled', true).parents('li').addClass('disabled'); | |
} | |
$checkbox.prop('checked', selected); | |
if (selected && this.options.selectedClass) { | |
$checkbox.parents('li').addClass(this.options.selectedClass); | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ware modified function arguments(added groupId argument) and on line 17 added attribute for group identification