From 96714d286e6910a1185aae27020dc62126a505de Mon Sep 17 00:00:00 2001
From: Tomas Kirda
Date: Thu, 27 Jun 2013 17:05:37 -0500
Subject: [PATCH] Add inner container, so that styling can be more flexible.
---
src/jquery.autocomplete.js | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/jquery.autocomplete.js b/src/jquery.autocomplete.js
index cc4e4b1a..d6983711 100644
--- a/src/jquery.autocomplete.js
+++ b/src/jquery.autocomplete.js
@@ -93,6 +93,7 @@
that.onChange = null;
that.isLocal = false;
that.suggestionsContainer = null;
+ that.innerContainer = null;
that.options = $.extend({}, defaults, options);
that.classes = {
selected: 'autocomplete-selected',
@@ -126,7 +127,8 @@
suggestionSelector = '.' + that.classes.suggestion,
selected = that.classes.selected,
options = that.options,
- container;
+ container,
+ innerContainer;
// Remove autocomplete attribute to prevent native suggestions:
that.element.setAttribute('autocomplete', 'off');
@@ -138,12 +140,13 @@
}
};
- that.suggestionsContainer = Autocomplete.utils.createNode('');
+ that.suggestionsContainer = Autocomplete.utils.createNode('');
container = $(that.suggestionsContainer);
-
container.appendTo(options.appendTo);
+ that.innerContainer = $('.autocomplete-inner', container);
+
// Only set width if it was provided:
if (options.width !== 'auto') {
container.width(options.width);
@@ -473,6 +476,7 @@
className = that.classes.suggestion,
classSelected = that.classes.selected,
container = $(that.suggestionsContainer),
+ innerContainer = that.innerContainer,
html = '',
width;
@@ -490,13 +494,14 @@
container.width(width > 0 ? width : 300);
}
- container.html(html).show();
+ innerContainer.html(html);
+ container.show();
that.visible = true;
// Select first value by default:
if (that.options.autoSelectFirst) {
that.selectedIndex = 0;
- container.children().first().addClass(classSelected);
+ innerContainer.children().first().addClass(classSelected);
}
that.findBestHint();