$(document).ready(function() {
$('#rahmen').multiselect({
numberDisplayed: 1,
includeSelectAllOption: true,
allSelectedText: 'Alle ausgewählt',
nonSelectedText: 'Keine ausgewählt',
selectAllValue: 'alle',
selectAllText: 'Alle wählen',
unselectAllText: 'Auswahl aufheben',
onSelectAll: function(checked) {
var all = $('#rahmen ~ .btn-group .dropdown-menu .multiselect-all .checkbox');
all
// get all child nodes including text and comment
.contents()
// iterate and filter out elements
.filter(function() {
// check node is text and non-empty
return this.nodeType === 3 && this.textContent.trim().length;
// replace it with new text
}).replaceWith(checked ? this.unselectAllText : this.selectAllText);
},
onChange: function() {
debugger;
var select = $(this.$select[0]);
var dropdown = $(this.$ul[0]);
var options = select.find('option').length;
var selected = select.find('option:selected').length;
var all = dropdown.find('.multiselect-all .checkbox');
all
// get all child nodes including text and comment
.contents()
// iterate and filter out elements
.filter(function() {
// check node is text and non-empty
return this.nodeType === 3 && this.textContent.trim().length;
// replace it with new text
}).replaceWith(options === selected ? this.options.unselectAllText : this.options.selectAllText);
}
});
$("#form").submit(function(e) {
e.preventDefault();
alert($(this).serialize());
});
});