diff --git a/auto-complete.css b/auto-complete.css
index 4261b1d..634abaa 100644
--- a/auto-complete.css
+++ b/auto-complete.css
@@ -4,6 +4,6 @@
/* core styles should not be changed */
position: absolute; display: none; z-index: 9999; max-height: 254px; overflow: hidden; overflow-y: auto; box-sizing: border-box;
}
-.autocomplete-suggestion { position: relative; padding: 0 .6em; line-height: 23px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1.02em; color: #333; }
+.autocomplete-suggestion, .noresults-suggestion { position: relative; padding: 0 .6em; line-height: 23px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1.02em; color: #333; }
.autocomplete-suggestion b { font-weight: normal; color: #1f8dd6; }
.autocomplete-suggestion.selected { background: #f0f0f0; }
diff --git a/auto-complete.js b/auto-complete.js
index 2f5a88c..b3d84aa 100644
--- a/auto-complete.js
+++ b/auto-complete.js
@@ -43,7 +43,12 @@ var autoComplete = (function(){
var re = new RegExp("(" + search.split(' ').join('|') + ")", "gi");
return '
Settings
delay | 150 | The delay in milliseconds between when a keystroke occurs and when a search is performed. A zero-delay is more responsive, but can produce a lot of load. |
offsetLeft | 0 | Optional left offset of the suggestions container. |
offsetTop | 1 | Optional top offset of the suggestions container. |
- cache | true | Determines if performed searches should be cached. |
+ cache | 1 | Determines if performed searches should be cached. Falsy values turn caching off, 1 turns on (legacy) non-strict cache-checking, any other numeric values turn on strict cache-checking. |
menuClass | '' |
Custom class/es that get/s added to the dropdown menu container.
@@ -127,6 +127,19 @@ Settings
}
|
+
+ renderNoResult | function |
+
+ A function that gives you control over what is displayed when there are no results to suggest. Default:
+renderNoResults: function(){
+ return '<div class="noresults-suggestion">No results returned</div>';
+}
+ |
+
+
+ widthScale | 1 |
+ Optional coefficient applied to base suggestion width. |
+
|
Callbacks | |
@@ -136,6 +149,21 @@ Settings
term is the selected value.
and item is the item rendered by the renderItem function.
+ preventSource(val) |
+ A callback function that fires before the source function would normally be called to evaluate conditions, and should return a truthy value.
+ val is the currently entered value.
+ |
+ sourcePrevented(val) |
+ A callback function that fires when the preventSource function returns true and the source function is prevented.
+ val is the value previously passed to preventSource.
+ |
+
+ valueFilter(val, lastVal) |
+ A callback function that fires prior to onSelect, allowing exact specification of how the new value should be handled, to provide to onSelect.
+ val is the new value from the last selection.
+ lastVal is the value currently stored.
+ valueFilter should return the appropriate value to be stored.
+ |
|
Public Methods | |
@@ -276,6 +304,12 @@ Advanced suggestions handling and custom layout
for (i=0;i