In web development, we must have encountered search functions such as Baidu and Google. So what can be done with automatic completion in smart forms? Let’s reveal it below:
1. Contains simple searches like Google, Baidu, etc.
2. Support for complex structures, such as entering a product number, you need to fill in a certain position in the meeting form for the product number, product name, product unit price, product notes, etc.
The code is as follows (page address: https://github.com/xiexingen/Bootstrap-SmartForm/blob/master/demo/form3-ele-autocomplete.html):
Automatic completion
Note: js files need to be introduced: jquery-ui.js, jquery.fn.extend.js
After the form generation is completed, call the SmartSearch method by specifying the element
Parameter description:
url: requested url
beforeSearch: Optional, the method called before sending the request. The method has a parameter data that contains the data to be sent. If you need to add or modify the parameters to be sent, you can modify the parameters again.
formatItem: Optional. If the returned is not a simple array string, you must customize the operation to format the content displayed on the interface. In the example, the product number + product name is displayed.
callback: optional. If the returned array string is not a simple array string, you must customize the operation and use it to assign values
note: If the interface returns a simple string array, formatItem and callback can be omitted.
Here is a screenshot of running in my local test project:
The above is the full description of the BootStrap smart form practical series (10) automatic component support introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support to Wulin.com website!