Commit cd210f94 authored by Chris Hynes's avatar Chris Hynes

Normalize prop access a la http://api.jquery.com/removeProp/

* Use prop("property", false), rather than removeProp("property")
* Use prop("selected", true), rather than prop("selected", "selected")
parent c7b5fb42
...@@ -129,8 +129,7 @@ ...@@ -129,8 +129,7 @@
// Will build an dropdown element for the given option. // Will build an dropdown element for the given option.
createOptionValue: function(element) { createOptionValue: function(element) {
if ($(element).is(':selected')) { if ($(element).is(':selected')) {
$(element).attr('selected', 'selected'); $(element).attr('selected', 'selected').prop('selected', true);
$(element).prop('selected', 'selected');
} }
// Support the label attribute on options. // Support the label attribute on options.
...@@ -148,7 +147,7 @@ ...@@ -148,7 +147,7 @@
$('ul', this.$container).append(li); $('ul', this.$container).append(li);
if ($(element).is(':disabled')) { if ($(element).is(':disabled')) {
checkbox.attr('disabled', 'disabled').prop('disabled', 'disabled').parents('li').addClass('disabled') checkbox.attr('disabled', 'disabled').prop('disabled', true).parents('li').addClass('disabled');
} }
checkbox.prop('checked', selected); checkbox.prop('checked', selected);
...@@ -206,12 +205,13 @@ ...@@ -206,12 +205,13 @@
var option = $('option', this.$select).filter(function() { return $(this).val() == $(event.target).val(); }); var option = $('option', this.$select).filter(function() { return $(this).val() == $(event.target).val(); });
var $optionsNotThis = $('option', this.$select).not($(option)); var $optionsNotThis = $('option', this.$select).not($(option));
var $checkboxesNotThis = $('input', this.$container).not($(event.target)); var $checkboxesNotThis = $('input', this.$container).not($(event.target));
if (isSelectAllOption) { if (isSelectAllOption) {
$checkboxesNotThis.filter(function () { return $(this).is(':checked') != checked; }).trigger('click'); $checkboxesNotThis.filter(function () { return $(this).is(':checked') != checked; }).trigger('click');
} }
if (checked) { if (checked) {
option.attr('selected', 'selected'); option.attr('selected', 'selected').prop('selected', true);
option.prop('selected', 'selected');
if (!this.options.multiple) { if (!this.options.multiple) {
if (this.options.selectedClass) { if (this.options.selectedClass) {
$($checkboxesNotThis).parents('li').removeClass(this.options.selectedClass); $($checkboxesNotThis).parents('li').removeClass(this.options.selectedClass);
...@@ -219,7 +219,7 @@ ...@@ -219,7 +219,7 @@
$($checkboxesNotThis).prop('checked', false); $($checkboxesNotThis).prop('checked', false);
$optionsNotThis.removeAttr('selected').removeProp('selected'); $optionsNotThis.removeAttr('selected').prop('selected', false);
// It's a single selection, so close. // It's a single selection, so close.
$(this.$container).find(".multiselect.dropdown-toggle").click(); $(this.$container).find(".multiselect.dropdown-toggle").click();
...@@ -339,8 +339,7 @@ ...@@ -339,8 +339,7 @@
checkbox.prop('checked', true); checkbox.prop('checked', true);
option.attr('selected', 'selected'); option.attr('selected', 'selected').prop('selected', true);
option.prop('selected', 'selected');
var options = this.getSelected(); var options = this.getSelected();
$('button', this.$container).html(this.options.buttonText(options, this.$select)); $('button', this.$container).html(this.options.buttonText(options, this.$select));
...@@ -357,8 +356,7 @@ ...@@ -357,8 +356,7 @@
checkbox.prop('checked', false); checkbox.prop('checked', false);
option.removeAttr('selected'); option.removeAttr('selected').prop('selected', false);
option.removeProp('selected');
var options = this.getSelected(); var options = this.getSelected();
$('button', this.$container).html(this.options.buttonText(options, this.$select)); $('button', this.$container).html(this.options.buttonText(options, this.$select));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment