I have typeahead.js from source:
https://github.com/twitter/typeahead.js
The following example does not fire a request to the server side script for querying the database:
HTML:
<input id="doc" class="typeahead" type="text" placeholder="search here">
JS
$('#doc').typeahead({
name: 'doc-search',
minLength: 3,
limit: 10,
remote: '/Search&doc_no=%QUERY'
});
I don't see any calls being made to /Search
in the developer console.
.typeahead
doesn't contain definition for remote
you need to use Bloodhound
to fetch data remotely.
Here is an example of how you can fetch data remotely.
var docs = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('YourColumnName'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
remote: '/Search&doc_no=%QUERY',
wildcard: '%QUERY'
}
});
$('#doc').typeahead(null, {
name: 'documents',
display: 'value',
source: docs
});
You can see Remote
section of examples page.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.