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

cleaned up loading/cleaning of result list

This commit is contained in:
Igor Vaynberg 2012-03-27 15:06:42 -07:00
parent 2dc46c4bfa
commit f4e0089b1f

View File

@ -356,8 +356,11 @@
this.container.addClass("select2-dropdown-open").addClass("select2-container-active"); this.container.addClass("select2-dropdown-open").addClass("select2-container-active");
this.updateResults();
this.ensureHighlightVisible();
this.alignDropdown(); this.alignDropdown();
this.dropdown.show(); this.dropdown.show();
this.focusSearch();
}; };
AbstractSelect2.prototype.close = function () { AbstractSelect2.prototype.close = function () {
@ -365,15 +368,7 @@
this.dropdown.hide(); this.dropdown.hide();
this.container.removeClass("select2-dropdown-open"); this.container.removeClass("select2-dropdown-open");
this.results.empty();
if (this.select) {
// TODO see if we can always clear here and reset on open
this.search.val(""); // not using clearSearch() because it may set a placeholder
this.updateResults(); // needed since we just set the search text to ""
} else {
this.results.empty();
}
this.clearSearch(); this.clearSearch();
}; };
@ -610,12 +605,6 @@
width -= getSideBorderPadding(this.container.find(".select2-search")); width -= getSideBorderPadding(this.container.find(".select2-search"));
width -= getSideBorderPadding(this.search); width -= getSideBorderPadding(this.search);
this.search.css({width: width}); this.search.css({width: width});
if (!this.select) this.updateResults();
this.ensureHighlightVisible();
this.focusSearch();
}; };
SingleSelect2.prototype.close = function () { SingleSelect2.prototype.close = function () {
@ -915,7 +904,6 @@
if (this.opened()) return; if (this.opened()) return;
this.parent.open.apply(this, arguments); this.parent.open.apply(this, arguments);
this.resizeSearch(); this.resizeSearch();
this.ensureHighlightVisible();
this.focusSearch(); this.focusSearch();
}; };