Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[custom select] Filter placeholders out of the list of selected items…

… - Fixes: #4061
  • Loading branch information...
commit fd959b9829b9da5e71044e2934e80bf6756112d1 1 parent 4707068
@gabrielschulhof gabrielschulhof authored
Showing with 12 additions and 5 deletions.
  1. +12 −5 js/jquery.mobile.forms.select.custom.js
View
17 js/jquery.mobile.forms.select.custom.js
@@ -266,19 +266,22 @@ define( [
return options.text() !== list.text();
},
+ selected: function() {
+ return this._selectOptions().filter( ":selected:not(:jqmData(placeholder='true'))" );
+ },
+
refresh: function( forceRebuild , foo ){
var self = this,
select = this.element,
isMultiple = this.isMultiple,
- options = this._selectOptions(),
- selected = this.selected(),
- // return an array of all selected index's
- indicies = this.selectedIndices();
+ indices;
if ( forceRebuild || this._isRebuildRequired() ) {
self._buildList();
}
+ indicies = this.selectedIndices();
+
self.setButtonText();
self.setButtonCount();
@@ -461,6 +464,7 @@ define( [
dataIndexAttr = dataPrefix + 'option-index',
dataIconAttr = dataPrefix + 'icon',
dataRoleAttr = dataPrefix + 'role',
+ dataPlaceholderAttr = dataPrefix + 'placeholder',
fragment = document.createDocumentFragment(),
isPlaceholderItem = false,
optGroup;
@@ -493,6 +497,9 @@ define( [
if (needPlaceholder && (!option.getAttribute( "value" ) || text.length == 0 || $option.jqmData( "placeholder" ))) {
needPlaceholder = false;
isPlaceholderItem = true;
+
+ // If we have identified a placeholder, mark it retroactively in the select as well
+ option.setAttribute( dataPlaceholderAttr, true );
if ( o.hidePlaceholderMenuItems ) {
classes.push( "ui-selectmenu-placeholder" );
}
@@ -509,7 +516,7 @@ define( [
item.setAttribute(dataIndexAttr,i);
item.setAttribute(dataIconAttr,dataIcon);
if ( isPlaceholderItem ) {
- item.setAttribute( dataPrefix + "placeholder", true );
+ item.setAttribute( dataPlaceholderAttr, true );
}
item.className = classes.join(" ");
item.setAttribute('role','option');
Please sign in to comment.
Something went wrong with that request. Please try again.