Permalink
Browse files

Allow user to display the currently selected value inside the searchb…

…ox (only applies for single selects).
  • Loading branch information...
1 parent 1e9cfc7 commit 4ff5e7a97b43220d7ddfcfa8312c27baf0e35140 @jdecuyper committed Aug 9, 2012
Showing with 7 additions and 1 deletion.
  1. +7 −1 select2.js
View
@@ -1138,11 +1138,17 @@
updateResults: function (initial) {
var search = this.search, results = this.results, opts = this.opts, data, self=this, input;
+ // display currently selected value inside the searchbox (only for single select)
+ if (initial === true && opts.keepValOnSearch && search.val() == "" && opts.element.attr("multiple") == undefined) {
+ var selected = opts.element.find(":selected");
+ search.val(selected.text());
+ }
+
// if the search is currently hidden we do not alter the results
if (initial !== true && (this.showSearchInput === false || !this.opened())) {
return;
}
-
+
search.addClass("select2-active");
function postRender() {

0 comments on commit 4ff5e7a

Please sign in to comment.