data |
string|array |
null |
Data source. Array of objects or a URL to JSON string/file.
NOTE If using a URL, it will load the data once.
|
url |
string |
null |
URL to remote data source. This is useful when data is just too big to pass to data option.
The request parameters are:
keyword : Search keyword
load : Array of values flexdatalist is trying to load. Usually happens when setting the value directly, like on init or when adding a value.
selected : Currently selected value(s)
contain : The searchContain option value
-
Only on POST
options : Flexdatalist options
NOTE It will keep requesting the server for data whenever is appropriate. If possible, filter also on the server side to improve performance.
NOTE If data is also set, it will merge the remote data with current loaded data set in data .
TIP! Flexdatalist allows you to control option(s) from the backend. Expects a server response like:
{
"results":[
...
],
"options":{
"url":"/next-time-send-to-this-url"
}
}
|
params |
object |
{} |
Additional parameters on AJAX requests.
|
cache |
boolean |
true |
Cache for (repeated) remote requests.
|
cacheLifetime |
int |
60 |
Cache lifetime (in seconds).
|
multiple |
boolean |
false |
Accept multiple values
|
disabled |
boolean |
false |
Disabled field(s)
|
minLength |
integer |
2 |
Search if there are n or greater characters.
If set to 0 it will show all results on input focus.
NOTE If set to 0 we recommend using maxShownResults to improve performance.
|
searchContain |
boolean |
false |
By default, Flexdatalist's search matches starting at the beginning of a word.
Setting this option to true allows matches starting from anywhere within a word.
This is especially useful for options that include a lot of special characters or phrases in ()s and []s.
|
searchDisabled |
boolean |
false |
Disable search of keyword in data.
|
searchByWord |
boolean |
false |
If set to true , it will split the keyword's words and search for them individually.
|
maxShownResults |
integer |
100 |
Maximum number of results to show.
|
groupBy |
string |
null |
Group results by given property's name value.
|
selectionRequired |
boolean |
false |
Selection from search results is required.
|
focusFirstResult |
boolean |
false |
Focus first result.
|
searchIn |
string|array |
["label"] |
Name of property (or properties) where it will search.
|
searchDelay |
integer |
300 |
For each key press, delay search in n miliseconds. This prevents one search per keystroke.
|
noResultsText |
string |
'No results found for "{keyword}"' |
Text that will show when no results are found. If empty string, it won't show message.
|
visibleProperties |
array |
[] |
Name of properties values that will appear with the search result.
Each property value will be wrapped with a <span class="item item-the_property_name">Property Value</span> so that its possible to style the appearance of additional information in the results.
|
textProperty |
string |
null |
The text that will be visible to the user.
You can use {property_name} to be replaced with property value.
|
valueProperty |
string|object/array |
null |
The property name that when selected its value will be sent with the form.
If you wanna send properties from selected item, set this option to *
|
iconProperty |
string |
'thumb' |
Name of property that holds path to image to be added as icon.
|
normalizeString |
function |
null |
This allows you to normalize the strings being compared before comparison.
Useful when using tools like latinize .
Example:
$.flexdatalist({
normalizeString: function (string) {
return latinize(string);
}
});
|
relatives |
string|jQuery instance |
null |
Input relatives. Accepts field(s) selector(s) or an jQuery instance of the fields.
The relatives values will be sent with each request to remote server.
Example:
$.flexdatalist({
relatives: '#user_full_name'
});
|
chainedRelatives |
boolean |
false |
If set to true the flexdatalist field will be disabled until all the relatives are filled.
|
toggleSelected |
boolean |
false |
If set to true , in multiple values allows you to toggle the presence of the value.
|
requestType |
string |
'get' |
Allows you to set the type of request it will make.
|
requestContentType |
string |
'x-www-form-urlencoded' |
If you prefer to send data to remote server as JSON, set this option to 'json'
|
resultsProperty |
string |
'results' |
Flexdatalist expects the data from server to be in the main response object or responseObject.results but you can change the name of property that holds the results.
|
keywordParamName |
string |
'keyword' |
By default, flexdatalist sends the keyword in request parameter with name keyword .
|
allowDuplicateValues |
boolean |
false |
As the name suggests, it allows multiple options with the same value.
|
limitOfValues |
integer |
0 |
Limit the number of values in a multiple input.
0 to disable limit.
|
removeOnBackspace |
boolean |
true |
On backspace key, remove previous value (multiple values setting)
|
valuesSeparator |
string |
',' |
Delimiter used in multiple values.
|