gpt4 book ai didi

javascript - Twitter Typeahead.js 库是否仅限于 6 个数据集?

转载 作者:行者123 更新时间:2023-11-29 14:54:38 27 4
gpt4 key购买 nike

我正在使用 Typeahed.js来自 Twitter 的库从单个输入框搜索我的数据库中的多个数据集。

我目前正在使用 6 个数据集(参见下面的代码),我想再添加 1 个。我发现它不适用于第 7 个数据集(下面代码中的 products dataset)。当在输入框中输入搜索查询时,它只会发送前六个数据集的 GET AJAX 请求,而会忽略第 7 个数据集?

GET http://127.0.0.1/app/typeahead_orders.json?q=MSI-20mA
GET http://127.0.0.1/app/typeahead_invoices.json?q=MSI-20mA
GET http://127.0.0.1/app/typeahead_services.json?q=MSI-20mA%
GET http://127.0.0.1/app/typeahead_serials.json?q=MSI-20mA%
GET http://127.0.0.1/app/typeahead_users.json?q=MSI-20mA%
GET http://127.0.0.1/app/typeahead_licenses.json?q=MSI-20mA%

图书馆文档很烂,我还没有看到它提到对您可以使用的数据集数量的任何限制......

$('#search-query').typeahead([
{
name: 'orders',
remote: base_url+"utilities/ajaxprocess/typeahead_orders.json?q=%QUERY",
template: '<a href="'+base_url+'orders/view/{{order_id}}">{{value}} - Reference no.: {{reference_number}}</a>',
header: '<h5 class="search-result-header"><i class="icon-shopping-cart"></i> Orders</h5>',
engine: Hogan,
limit: 6
},
{
name: 'invoices',
remote: base_url+"utilities/ajaxprocess/typeahead_invoices.json?q=%QUERY",
template: '<a href="'+base_url+'invoices/view/{{invoice_id}}">{{invoice_number}} - {{company}}</a>',
header: '<h5 class="search-result-header"><i class="icon-file"></i> Invoices</h5>',
engine: Hogan,
limit: 6
},
{
name: 'services',
remote: base_url+"utilities/ajaxprocess/typeahead_services.json?q=%QUERY%",
template: '<a href="'+base_url+'services/view/{{rma_id}}">{{value}} - {{firstname}} {{lastname}}</a>',
header: '<h5 class="search-result-header"><i class="icon-wrench"></i> RMA services</h5>',
engine: Hogan,
limit: 6
},
{
name: 'serials',
remote: base_url+"utilities/ajaxprocess/typeahead_serials.json?q=%QUERY%",
template: '<a href="'+base_url+'serials/view/{{serial_id}}">{{value}} - {{product}} {{module_name}}</a>',
header: '<h5 class="search-result-header"><i class="icon-barcode"></i> Serials</h5>',
engine: Hogan,
limit: 6
},
{
name: 'users',
remote: base_url+"utilities/ajaxprocess/typeahead_users.json?q=%QUERY%",
template: '<a href="'+base_url+'users?f=1&filter_id={{user_id}}">{{firstname}} {{lastname}} - {{email}}</a>',
header: '<h5 class="search-result-header"><i class="icon-user"></i> Users</h5>',
engine: Hogan,
limit: 6
},
{
name: 'licenses',
remote: base_url+"utilities/ajaxprocess/typeahead_licenses.json?q=%QUERY%",
template: '<a href="'+base_url+'licenses?f=1&filter_id={{license_id}}">{{key}} - {{version}}</a>',
header: '<h5 class="search-result-header"><i class="icon-lock"></i> Licenses</h5>',
engine: Hogan,
limit: 6
},
{
name: 'products',
remote: base_url+"utilities/ajaxprocess/typeahead_products.json?q=%QUERY%",
template: '<a href="'+base_url+'products?f=1&filter_id={{product_id}}">{{code}} - {{name}}</a>',
header: '<h5 class="search-result-header"><i class="icon-briefcase"></i> Products</h5>',
engine: Hogan,
limit: 6
}
]).on('typeahead:selected', function($e, data) {
window.location = data.url;
});

最佳答案

好吧,我明白了。它不受限制,但默认最大并行请求为 6。来自 typeahead.js 文档:

maxParallelRequests – The max number of parallel requests typeahead.js can have pending. Defaults to 6.

所以我增加了这个并且它起作用了。这是最终更正后的代码:

$('#search-query').typeahead([
{
name: 'orders',
remote: {
url: base_url+"utilities/ajaxprocess/typeahead_orders.json?q=%QUERY",
maxParallelRequests: 8,
},
template: '<a href="'+base_url+'orders/view/{{order_id}}">{{value}} - Reference no.: {{reference_number}}</a>',
header: '<h5 class="search-result-header"><i class="icon-shopping-cart"></i> Orders</h5>',
engine: Hogan,
limit: 6
},
{
name: 'invoices',
remote: {
url: base_url+"utilities/ajaxprocess/typeahead_invoices.json?q=%QUERY",
maxParallelRequests: 8,
},
template: '<a href="'+base_url+'invoices/view/{{invoice_id}}">{{invoice_number}} - {{company}}</a>',
header: '<h5 class="search-result-header"><i class="icon-file"></i> Invoices</h5>',
engine: Hogan,
limit: 6
},
{
name: 'services',
remote: {
url: base_url+"utilities/ajaxprocess/typeahead_services.json?q=%QUERY%",
maxParallelRequests: 8,
},
template: '<a href="'+base_url+'services/view/{{rma_id}}">{{value}} - {{firstname}} {{lastname}}</a>',
header: '<h5 class="search-result-header"><i class="icon-wrench"></i> RMA services</h5>',
engine: Hogan,
limit: 6
},
{
name: 'serials',
remote: {
url: base_url+"utilities/ajaxprocess/typeahead_serials.json?q=%QUERY%",
maxParallelRequests: 8,
},
template: '<a href="'+base_url+'serials/view/{{serial_id}}">{{value}} - {{product}} {{module_name}}</a>',
header: '<h5 class="search-result-header"><i class="icon-barcode"></i> Serials</h5>',
engine: Hogan,
limit: 6
},
{
name: 'users',
remote: {
url: base_url+"utilities/ajaxprocess/typeahead_users.json?q=%QUERY%",
maxParallelRequests: 8,
},
template: '<a href="'+base_url+'users?f=1&filter_id={{user_id}}">{{firstname}} {{lastname}} - {{email}}</a>',
header: '<h5 class="search-result-header"><i class="icon-user"></i> Users</h5>',
engine: Hogan,
limit: 6
},
{
name: 'licenses',
remote: {
url: base_url+"utilities/ajaxprocess/typeahead_licenses.json?q=%QUERY%",
maxParallelRequests: 8,
},
template: '<a href="'+base_url+'licenses?f=1&filter_id={{license_id}}">{{key}} - {{version}}</a>',
header: '<h5 class="search-result-header"><i class="icon-lock"></i> Licenses</h5>',
engine: Hogan,
limit: 6
},
{
name: 'products',
remote: {
url: base_url+"utilities/ajaxprocess/typeahead_products.json?q=%QUERY%",
maxParallelRequests: 8,
},
template: '<a href="'+base_url+'products?f=1&filter_id={{product_id}}">{{code}} - {{name}}</a>',
header: '<h5 class="search-result-header"><i class="icon-briefcase"></i> Products</h5>',
engine: Hogan,
limit: 6
},
{
name: 'tasks',
remote: {
url: base_url+"utilities/ajaxprocess/typeahead_tasks.json?q=%QUERY%",
maxParallelRequests: 8,
},
template: '<a href="'+base_url+'tasks?f=1&filter_id={{task_id}}">#{{task_id}} - {{description}}</a>',
header: '<h5 class="search-result-header"><i class="icon-briefcase"></i> Tasks</h5>',
engine: Hogan,
limit: 6
}
]).on('typeahead:selected', function($e, data) {
window.location = data.url;
});

关于javascript - Twitter Typeahead.js 库是否仅限于 6 个数据集?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19944179/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com