Skip to content

Commit

Permalink
Added closeOnSelect parameter for single value selects2 widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
Nils Kaiser committed Nov 21, 2012
1 parent 739a7bf commit c7a7504
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions select2.js
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,9 @@ the specific language governing permissions and limitations under the Apache Lic
highlighted=this.results.find(".select2-highlighted").not(".select2-disabled"),
data = highlighted.closest('.select2-result-selectable').data("select2-data");
if (data) {
highlighted.addClass("select2-disabled");
if (this.opts.multiple || this.opts.closeOnSelect) {
highlighted.addClass("select2-disabled");
}
this.highlight(index);
this.onSelect(data);
}
Expand Down Expand Up @@ -1694,8 +1696,11 @@ the specific language governing permissions and limitations under the Apache Lic

this.opts.element.val(this.id(data));
this.updateSelection(data);
this.close();
this.selection.focus();

if (this.opts.closeOnSelect) {
this.close();
this.selection.focus();
}

if (!equal(old, this.id(data))) { this.triggerChange(); }
},
Expand Down

0 comments on commit c7a7504

Please sign in to comment.