Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions select2.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Version: 3.2 Timestamp: Mon Sep 10 10:38:04 PDT 2012
vertical-align: top;
padding: 0;
border: 0;
/* force width to 100% */
width:100%\9;
}
/* To override styles found in Bootstrap3 */
.select2-container:hover {
Expand Down Expand Up @@ -368,6 +370,10 @@ disabled look for already selected choices in the results dropdown
.select2-results .select2-disabled {
display: none;
}
/* Hide selected items */
.select2-results .select2-selected {
display: none;
}

.select2-more-results.select2-active {
background: #f4f4f4 url('spinner.gif') no-repeat 100%;
Expand Down
13 changes: 11 additions & 2 deletions select2.js
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,16 @@ the specific language governing permissions and limitations under the Apache Lic
return equal(id, opts.id(el));
},
callback: !$.isFunction(callback) ? $.noop : function(filtered) {
callback(filtered.results.length ? filtered.results[0] : null);
if (filtered.results.length){
var r1 = filtered.results[0];
//If we have two-level menu, and the top level can not be selected(no id),
//we should return the children node to selected when only one child existed
if (!r1.id && r1.children && r1.children.length === 1){
callback(r1.children[0]);
}else{
callback(r1);
}
}
}
});
};
Expand Down Expand Up @@ -2675,4 +2684,4 @@ the specific language governing permissions and limitations under the Apache Lic
}
};

}(jQuery));
}(jQuery));