<input id="auto-complete" type="text">var data = [
"Bob",
"Dave",
"Steve",
"Kate",
"Bill",
"Alejandro"
]
new hx.AutoComplete("#auto-complete", data)hx.Autocomplete (lowercase c) [
"Bob",
"Steve",
...
]inputMap must be provided in the options: data = [
{
name "Bob",
age: 21
},
{
name: "Steve",
age: 25
}
]
options = {
inputMap: function(item){
return item.name + ', ' + item.age
}
}renderer and filterOptions.searchValues can also be specified to change how the text is displayed and what data is searchable, independent of the inputMap var data = function(term, callback){
hx.json('path/to/data?search='+term, function (e, r) {
callback(r.responseText)
})
}matchType to 'external': function data (term, callback) {
if (term.length > 0) {
return callback(townAndCountyData.filter(function (d) {
var d = townAndCountyData[_i]
var name = d.name.toLowerCase()
var term = term.toLowerCase()
var county = d.county.toLowerCase()
return name.indexOf(term) > -1 || county.indexOf(term) > -1)
}))
} else {
return callback([])
}
}
options.matchType = 'external'searchValues option uses the passed in input map to search on. var data = [
{
name: 'Bob'
age: 12
},
{
name: 'Alice'
age: 19
},
{
name: 'Jane'
age: 42
}
]
function inputMap (item) {
return item.name + ', ' + item.age
}hx.filter functions. All the filter types can be specified as the match type (e.g. 'startsWith', 'exact' or 'fuzzy') and the default value is 'contains'. hx.userFacingText('autocomplete', 'noResultsFound')showOtherResults option is true. undefined or '' will not prevent the heading from showing as it acts as a divider between matching and non-matching results. hx.userFacingText('autocomplete', 'otherResults')'$minLength' variable, e.g. options = {
minLength: 3,
pleaseEnterMinCharactersMessage = 'Please enter $minLength characters'
}
// Evaluates to 'Please enter 3 characters'hx.userFacingText('autocomplete', 'pleaseEnterMinCharacters')function renderer (elem, item){
hx.select(elem)
.text(item)
}[
"Bob",
"Steve",
...
]inputMap must be provided in the options: data = [
{
name "Bob",
age: 21
},
{
name: "Steve",
age: 25
}
]
options = {
inputMap: function(item){
return item.name + ', ' + item.age
}
}renderer and filterOptions.searchValues can also be specified to change how the text is displayed and what data is searchable, independent of the inputMap var data = function(term, callback){
hx.json('path/to/data?search='+term, function (e, r) {
callback(r.responseText)
})
}matchType to 'external': function data (term, callback) {
if (term.length > 0) {
return callback(townAndCountyData.filter(function (d) {
var d = townAndCountyData[_i]
var name = d.name.toLowerCase()
var term = term.toLowerCase()
var county = d.county.toLowerCase()
return name.indexOf(term) > -1 || county.indexOf(term) > -1)
}))
} else {
return callback([])
}
}
options.matchType = 'external'searchValues option uses the passed in input map to search on. var data = [
{
name: 'Bob'
age: 12
},
{
name: 'Alice'
age: 19
},
{
name: 'Jane'
age: 42
}
]
function inputMap (item) {
return item.name + ', ' + item.age
}hx.filter functions. All the filter types can be specified as the match type (e.g. 'startsWith', 'exact' or 'fuzzy') and the default value is 'contains'. hx.userFacingText('autocomplete', 'noResultsFound')showOtherResults option is true. undefined or '' will not prevent the heading from showing as it acts as a divider between matching and non-matching results. hx.userFacingText('autocomplete', 'otherResults')'$minLength' variable, e.g. options = {
minLength: 3,
pleaseEnterMinCharactersMessage = 'Please enter $minLength characters'
}
// Evaluates to 'Please enter 3 characters'hx.userFacingText('autocomplete', 'pleaseEnterMinCharacters')function renderer (elem, item){
hx.select(elem)
.text(item)
}hx.autocomplete (lowercase c) [
"Bob",
"Steve",
...
]inputMap must be provided in the options: data = [
{
name "Bob",
age: 21
},
{
name: "Steve",
age: 25
}
]
options = {
inputMap: function(item){
return item.name + ', ' + item.age
}
}renderer and filterOptions.searchValues can also be specified to change how the text is displayed and what data is searchable, independent of the inputMap var data = function(term, callback){
hx.json('path/to/data?search='+term, function (e, r) {
callback(r.responseText)
})
}matchType to 'external': function data (term, callback) {
if (term.length > 0) {
return callback(townAndCountyData.filter(function (d) {
var d = townAndCountyData[_i]
var name = d.name.toLowerCase()
var term = term.toLowerCase()
var county = d.county.toLowerCase()
return name.indexOf(term) > -1 || county.indexOf(term) > -1)
}))
} else {
return callback([])
}
}
options.matchType = 'external'searchValues option uses the passed in input map to search on. var data = [
{
name: 'Bob'
age: 12
},
{
name: 'Alice'
age: 19
},
{
name: 'Jane'
age: 42
}
]
function inputMap (item) {
return item.name + ', ' + item.age
}hx.filter functions. All the filter types can be specified as the match type (e.g. 'startsWith', 'exact' or 'fuzzy') and the default value is 'contains'. hx.userFacingText('autocomplete', 'noResultsFound')showOtherResults option is true. undefined or '' will not prevent the heading from showing as it acts as a divider between matching and non-matching results. hx.userFacingText('autocomplete', 'otherResults')'$minLength' variable, e.g. options = {
minLength: 3,
pleaseEnterMinCharactersMessage = 'Please enter $minLength characters'
}
// Evaluates to 'Please enter 3 characters'hx.userFacingText('autocomplete', 'pleaseEnterMinCharacters')function renderer (elem, item){
hx.select(elem)
.text(item)
}[
"Bob",
"Steve",
...
]inputMap must be provided in the options: data = [
{
name "Bob",
age: 21
},
{
name: "Steve",
age: 25
}
]
options = {
inputMap: function(item){
return item.name + ', ' + item.age
}
}renderer and filterOptions.searchValues can also be specified to change how the text is displayed and what data is searchable, independent of the inputMap var data = function(term, callback){
hx.json('path/to/data?search='+term, function (e, r) {
callback(r.responseText)
})
}matchType to 'external': function data (term, callback) {
if (term.length > 0) {
return callback(townAndCountyData.filter(function (d) {
var d = townAndCountyData[_i]
var name = d.name.toLowerCase()
var term = term.toLowerCase()
var county = d.county.toLowerCase()
return name.indexOf(term) > -1 || county.indexOf(term) > -1)
}))
} else {
return callback([])
}
}
options.matchType = 'external'searchValues option uses the passed in input map to search on. var data = [
{
name: 'Bob'
age: 12
},
{
name: 'Alice'
age: 19
},
{
name: 'Jane'
age: 42
}
]
function inputMap (item) {
return item.name + ', ' + item.age
}hx.filter functions. All the filter types can be specified as the match type (e.g. 'startsWith', 'exact' or 'fuzzy') and the default value is 'contains'. hx.userFacingText('autocomplete', 'noResultsFound')showOtherResults option is true. undefined or '' will not prevent the heading from showing as it acts as a divider between matching and non-matching results. hx.userFacingText('autocomplete', 'otherResults')'$minLength' variable, e.g. options = {
minLength: 3,
pleaseEnterMinCharactersMessage = 'Please enter $minLength characters'
}
// Evaluates to 'Please enter 3 characters'hx.userFacingText('autocomplete', 'pleaseEnterMinCharacters')function renderer (elem, item){
hx.select(elem)
.text(item)
}