1
0
mirror of synced 2024-11-28 23:56:03 +03:00

Improve performance on dropdown detaching

Signed-off-by: Igor Vaynberg <igor.vaynberg@github.com>
This commit is contained in:
Aziz Gazanchiyan 2012-06-17 16:47:56 +03:00 committed by Igor Vaynberg
parent a0f067c2b2
commit 693b541361

View File

@ -483,6 +483,8 @@
prepareOpts: function (opts) {
var element, select, idKey;
opts.elementBody = opts.element.closest("body"); // cache for future access
element = opts.element;
@ -686,7 +688,11 @@
this.clearPlaceholder();
this.container.addClass("select2-dropdown-open").addClass("select2-container-active");
this.dropdown.detach().appendTo(this.opts.element.parents("body")).addClass("select2-drop-active");
if(this.dropdown[0] !== this.opts.elementBody.children().last()[0]) { // ensure our dropdown is the last eleemnt, so the z-index is always respected correctly
this.dropdown.detach().appendTo(this.opts.elementBody);
}
this.dropdown.addClass("select2-drop-active");
this.positionDropdown();