Available data sources
In simplest scenarios, defined in Basic Usage page, you just need to pass couple of parameters. However, in most cases, you would need to define your own data retrieval function to support more complex business logic.
getData
To support custom data retrieval LtS exposes getData
function. This function doesn’t need to return any data and expects 3 parameters:
searchTerm
- LtS will pass searchTerm that your user is currently typing, so you can process it within your data retrival logicsuccessHandler
- function provided by Select2 to handle success and process resultserrorHandler
- function provided by Select2 to handle errors
So let’s say you need to filter your employers (accounts) by name. To do so we can write custom getEmployerByName function and pass it as a getData parameter
data
You might also have certain scenarios when you want to show only predefined list of data. In that case you can supply data
variable to the LtS.
data
needs to be an array of objects, each object with 2 properties: id and text.