【发布时间】:2016-04-02 19:23:46
【问题描述】:
我在使用 Algolia instantsearch.js 的 searchBox 小部件时遇到错误错误消息如下:
indexName 无效
这个错误很奇怪,因为它不仅存在,而且还在显示结果!每次我在 searchBox 小部件中输入内容时,问题都会重复出现,并且结果不会被我输入的任何内容过滤。我创建了一个 plunker,看看是否有人可以告诉我我做错了什么。
http://plnkr.co/edit/ihz5VMZ6HUDaYKTqwo9V?p=preview
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="//cdn.jsdelivr.net/instantsearch.js/1/instantsearch.min.css">
<script src="//cdn.jsdelivr.net/instantsearch.js/1/instantsearch.min.js"></script>
</head>
<body>
<input type="text" id="search-box" class="form-control">
<table class="table table-striped">
<thead>
<tr>
<th>Number</th>
<th>Name</th>
<th>Starts</th>
<th>Duration</th>
<th>Room</th>
<th><span class="glyphicon glyphicon-info-sign"></span></th>
</tr>
</thead>
<tbody id="hits-container">
</tbody>
</table>
<div id="pagination-container"></div>
<script>
var search = instantsearch({
appId: '5V0BUFDX8J',
apiKey: 'a25692c12853aea7a77c5a7125498512',
indexName: 'C86FE050-6C48-11E5-84AA-BA5F164D0BA4_events',
urlSync: true
});
search.addWidget(
instantsearch.widgets.searchBox({
container: '#search-box',
autofocus: true,
placeholder: 'Search for events by keyword, description, or event number.'
})
);
search.addWidget(
instantsearch.widgets.hits({
container: '#hits-container',
templates: {
empty: 'No events found',
item: '<tr><td><a href="{{view_uri}}">{{event_number}}</a></td><td><a href="{{view_uri}}" target="_new">{{name}}</a></td><td>{{startdaypart_name}}</td><td>{{duration_name}}</td><td>{{room_name}}</td><td><span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" title="{{description}}"></span></td></tr>'
},
})
);
search.addWidget(
instantsearch.widgets.pagination({
container: '#pagination-container'
})
);
search.start();
</script>
</body>
</html>
【问题讨论】:
-
看起来您提供的链接返回错误:“无法连接到任何应用程序实例”。有什么想法吗?
标签: algolia