From 9c1caa6d3a4012687e01802190e7db91091cab6c Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Mon, 6 May 2013 19:25:09 -0700 Subject: [PATCH] add handling of autofocus attribute. fixes #837 --- select2.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/select2.js b/select2.js index fbfe62ab..1a5665ba 100644 --- a/select2.js +++ b/select2.js @@ -736,6 +736,10 @@ the specific language governing permissions and limitations under the Apache Lic // Calculate size of scrollbar scrollBarDimensions = scrollBarDimensions || measureScrollbar(); + + this.autofocus = opts.element.prop("autofocus") + opts.element.prop("autofocus", false); + if (this.autofocus) this.focus(); }, // abstract @@ -753,6 +757,7 @@ the specific language governing permissions and limitations under the Apache Lic .removeData("select2") .unbind(".select2") .attr({"tabindex": this.elementTabIndex}) + .prop("autofocus", this.autofocus) .show(); } }, @@ -1886,6 +1891,7 @@ the specific language governing permissions and limitations under the Apache Lic this.initContainerWidth(); this.opts.element.addClass("select2-offscreen"); this.setPlaceholder(); + }, // single