From ce67f7b7fb1352929cfb8bb6cc709512f674ccd6 Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Wed, 19 Jun 2013 22:38:46 -0700 Subject: [PATCH] fix #1426 - reinitting screws up tabindex --- select2.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/select2.js b/select2.js index 9a500b95..30b83703 100644 --- a/select2.js +++ b/select2.js @@ -763,21 +763,24 @@ the specific language governing permissions and limitations under the Apache Lic // abstract destroy: function () { - var select2 = this.opts.element.data("select2"); + var element=this.opts.element, select2 = element.data("select2"); if (this.propertyObserver) { delete this.propertyObserver; this.propertyObserver = null; } if (select2 !== undefined) { - select2.container.remove(); select2.dropdown.remove(); - select2.opts.element + element .removeClass("select2-offscreen") .removeData("select2") .off(".select2") - .attr({"tabindex": this.elementTabIndex}) - .prop("autofocus", this.autofocus||false) - .show(); + .prop("autofocus", this.autofocus || false); + if (this.elementTabIndex) { + element.attr({tabindex: this.elementTabIndex}); + } else { + element.removeAttr("tabindex"); + } + element.show(); } },