autocomplete, continued
This commit is contained in:
parent
8f18c726b6
commit
07ec8f30f7
2 changed files with 7 additions and 5 deletions
|
@ -1537,7 +1537,7 @@ requires
|
||||||
.defaults({
|
.defaults({
|
||||||
autocomplete: null,
|
autocomplete: null,
|
||||||
id: "",
|
id: "",
|
||||||
placeholder: "",
|
placeholder: "", // can be [], will result in select
|
||||||
size: "medium",
|
size: "medium",
|
||||||
type: "text"
|
type: "text"
|
||||||
})
|
})
|
||||||
|
@ -1577,7 +1577,7 @@ requires
|
||||||
var selected = 0;
|
var selected = 0;
|
||||||
if (items.length) {
|
if (items.length) {
|
||||||
items = $.map(items, function(title, position) {
|
items = $.map(items, function(title, position) {
|
||||||
if (that.val().toLowerCase() == title.toLowerCase()) {
|
if (that.val().toLowerCase() == Ox.stripTags(title.toLowerCase())) {
|
||||||
selected = position;
|
selected = position;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
@ -1622,7 +1622,7 @@ requires
|
||||||
var value = that.val();
|
var value = that.val();
|
||||||
if (self.options.autocomplete && value != self.value) {
|
if (self.options.autocomplete && value != self.value) {
|
||||||
self.value = value;
|
self.value = value;
|
||||||
self.options.autocomplete(self.value, autocomplete);
|
self.options.autocomplete(value, autocomplete);
|
||||||
}
|
}
|
||||||
}, 25);
|
}, 25);
|
||||||
}
|
}
|
||||||
|
|
|
@ -331,7 +331,6 @@
|
||||||
autocomplete: function(value, callback) {
|
autocomplete: function(value, callback) {
|
||||||
value = value.toLowerCase();
|
value = value.toLowerCase();
|
||||||
var items = [],
|
var items = [],
|
||||||
regexp = new RegExp("(" + value + ")", "ig"),
|
|
||||||
states = [
|
states = [
|
||||||
"Alabama", "Alaska", "Arizona", "Arkansas", "California",
|
"Alabama", "Alaska", "Arizona", "Arkansas", "California",
|
||||||
"Colorado", "Connecticut", "Delaware", "District of Columbia", "Florida",
|
"Colorado", "Connecticut", "Delaware", "District of Columbia", "Florida",
|
||||||
|
@ -350,7 +349,10 @@
|
||||||
} else {
|
} else {
|
||||||
$.each(states, function(i, state) {
|
$.each(states, function(i, state) {
|
||||||
if (state.toLowerCase().indexOf(value) > -1) {
|
if (state.toLowerCase().indexOf(value) > -1) {
|
||||||
items.push(state.replace(regexp, "<span class=\"OxHighlight\">$1</span>"));
|
items.push(state.replace(
|
||||||
|
new RegExp("(" + value + ")", "ig"),
|
||||||
|
"<span class=\"OxHighlight\">$1</span>")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue