Search 利用Bootstrap';s作为搜索功能提前键入
我的typeahead工作得很好,但我对Javascript太缺乏经验,无法理解如何将键入的结果转换为链接Search 利用Bootstrap';s作为搜索功能提前键入,search,twitter-bootstrap,bootstrap-typeahead,typeahead,Search,Twitter Bootstrap,Bootstrap Typeahead,Typeahead,我的typeahead工作得很好,但我对Javascript太缺乏经验,无法理解如何将键入的结果转换为链接 <input type="text" class="span3" data-provide="typeahead" placeholder="City Search:" data-items="6"
<input type="text"
class="span3"
data-provide="typeahead"
placeholder="City Search:"
data-items="6"
autocomplete="off"
data-source=["Neuchatel","Moutier"]">
您可以轻松地将字符串转换为链接
<input type="text" data-provide="typeahead" data-source="["/foo.html","http://www.google.com","/about.html"]">
然后你就可以开始打字了。source
和updater
函数将被定义为处理1)从map对象创建typeahead数据源数组,以及2)在选择项目时导航到适当的url
$('.typeahead').typeahead({
minLength:2,
updater: function (item) {
/* navigate to the selected item */
window.location.href = data[item];
},
source: function (typeahead, query) {
var links=[];
for (var name in data){
links.push(name);
}
return links;
}
});
您可以轻松地将字符串转换为链接
<input type="text" data-provide="typeahead" data-source="["/foo.html","http://www.google.com","/about.html"]">
然后你就可以开始打字了。source
和updater
函数将被定义为处理1)从map对象创建typeahead数据源数组,以及2)在选择项目时导航到适当的url
$('.typeahead').typeahead({
minLength:2,
updater: function (item) {
/* navigate to the selected item */
window.location.href = data[item];
},
source: function (typeahead, query) {
var links=[];
for (var name in data){
links.push(name);
}
return links;
}
});
thx,我确实在尝试导航到该页面。这个想法是让用户输入一个城市,名字会弹出,然后他们选择它。然后他们被引导到该页面。有点像一个简单的html链接,但包含在字符串中。这家伙似乎在同一条轨道上,但我不知道如何存储确切的URL@Skelly为什么不为此使用自定义模板呢?thx,我确实在尝试导航到该页面。这个想法是让用户输入一个城市,名字会弹出,然后他们选择它。然后他们被引导到该页面。有点像一个简单的html链接,但包含在字符串中。这家伙似乎在同一条轨道上,但我不知道如何存储确切的URL@Skelly为什么不为此使用自定义模板?