Javascript Meteor 0.6.5.1和twitter typeahead.js-(如何)工作?
我从TwitterBootstrap 2切换到Bootstrap 3,发现自己没有typeahead,建议现在就使用TwitterTypeahead.js。相应的似乎是最新的方面,但可能已经过时的最新更新的流星。对我来说,它不能正常工作 是否有人知道如何在Meteor中运行typeahead.js,或者确认我只是用错了 从我的代码中,我得到了一个混乱的格式: 谢谢你的提示 typeahead.htmlJavascript Meteor 0.6.5.1和twitter typeahead.js-(如何)工作?,javascript,twitter-bootstrap,meteor,twitter-bootstrap-3,typeahead.js,Javascript,Twitter Bootstrap,Meteor,Twitter Bootstrap 3,Typeahead.js,我从TwitterBootstrap 2切换到Bootstrap 3,发现自己没有typeahead,建议现在就使用TwitterTypeahead.js。相应的似乎是最新的方面,但可能已经过时的最新更新的流星。对我来说,它不能正常工作 是否有人知道如何在Meteor中运行typeahead.js,或者确认我只是用错了 从我的代码中,我得到了一个混乱的格式: 谢谢你的提示 typeahead.html <head> <title>typeahead</titl
<head>
<title>typeahead</title>
</head>
<body>
{{> hello}}
</body>
<template name="hello">
<form class="form-inline" role="form">
<div class="form-group">
<input class="form-control" type="text" id="typeahead">
</div>
</form>
</template>
我可以用这里的答案来解决这个问题 关于如何在《流星》中做到这一点。在渲染函数中,填充typeahead
var items = [],
finalItems,
tags = Tags.find({}, {fields: {name: 1, submitted: 0}});
tags.forEach(function(tag){
items.push(tag.name);
});
finalItems = _.uniq(items)
$('#search').typeahead({
local: finalItems
});
然后,在keyup事件中,执行以下操作
$('.tt-query').css('background-color','#fff');
$('#search').removeClass('tt-query');
在css中,添加
.twitter-typeahead{
width:100%;
}
.twitter-typeahead .tt-query,
.twitter-typeahead .tt-hint {
margin-bottom: 0;
}
.tt-dropdown-menu {
min-width: 160px;
margin-top: 2px;
padding: 5px 0;
background-color: #fff;
border: 1px solid #ccc;
border: 1px solid rgba(0,0,0,.2);
*border-right-width: 2px;
*border-bottom-width: 2px;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
-webkit-box-shadow: 0 5px 10px rgba(0,0,0,.2);
-moz-box-shadow: 0 5px 10px rgba(0,0,0,.2);
box-shadow: 0 5px 10px rgba(0,0,0,.2);
-webkit-background-clip: padding-box;
-moz-background-clip: padding;
background-clip: padding-box;
}
.tt-suggestion {
display: block;
padding: 3px 20px;
}
.tt-suggestion.tt-is-under-cursor {
color: #fff;
background-color: #0081c2;
background-image: -moz-linear-gradient(top, #0088cc, #0077b3);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0077b3));
background-image: -webkit-linear-gradient(top, #0088cc, #0077b3);
background-image: -o-linear-gradient(top, #0088cc, #0077b3);
background-image: linear-gradient(to bottom, #0088cc, #0077b3);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0077b3', GradientType=0)
}
.tt-suggestion.tt-is-under-cursor a {
color: #fff;
}
.tt-suggestion p {
margin: 0;
}
这是一个非常粗糙的问题,但在他们获得Typeahead和Bootstrap 3之前,它将一直有效。我能够使用这里的答案实现这一点 关于如何在《流星》中做到这一点。在渲染函数中,填充typeahead
var items = [],
finalItems,
tags = Tags.find({}, {fields: {name: 1, submitted: 0}});
tags.forEach(function(tag){
items.push(tag.name);
});
finalItems = _.uniq(items)
$('#search').typeahead({
local: finalItems
});
然后,在keyup事件中,执行以下操作
$('.tt-query').css('background-color','#fff');
$('#search').removeClass('tt-query');
在css中,添加
.twitter-typeahead{
width:100%;
}
.twitter-typeahead .tt-query,
.twitter-typeahead .tt-hint {
margin-bottom: 0;
}
.tt-dropdown-menu {
min-width: 160px;
margin-top: 2px;
padding: 5px 0;
background-color: #fff;
border: 1px solid #ccc;
border: 1px solid rgba(0,0,0,.2);
*border-right-width: 2px;
*border-bottom-width: 2px;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
-webkit-box-shadow: 0 5px 10px rgba(0,0,0,.2);
-moz-box-shadow: 0 5px 10px rgba(0,0,0,.2);
box-shadow: 0 5px 10px rgba(0,0,0,.2);
-webkit-background-clip: padding-box;
-moz-background-clip: padding;
background-clip: padding-box;
}
.tt-suggestion {
display: block;
padding: 3px 20px;
}
.tt-suggestion.tt-is-under-cursor {
color: #fff;
background-color: #0081c2;
background-image: -moz-linear-gradient(top, #0088cc, #0077b3);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0077b3));
background-image: -webkit-linear-gradient(top, #0088cc, #0077b3);
background-image: -o-linear-gradient(top, #0088cc, #0077b3);
background-image: linear-gradient(to bottom, #0088cc, #0077b3);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0077b3', GradientType=0)
}
.tt-suggestion.tt-is-under-cursor a {
color: #fff;
}
.tt-suggestion p {
margin: 0;
}
这是一个相当粗糙的程序,但它会一直工作,直到他们实现了Typeahead和Bootstrap 3的完美配合。如果你想要普通的免费文本自动完成,你可能想看看我的meteor自动完成软件包,几天前刚刚发布: 你也可以从那里得到一些灵感,来做你想做的事情。我强烈推荐Meteor collection支持的实现,而不是尝试使用现有的异步库拼凑一些东西,这就是我在这里所做的。这使得autocomplete能够完全响应和客户端(列表内容可以在您查看时更新!),而且速度更快 下面的一些图片
@
自动完成用户,其中在线用户显示为绿色:
请用叉子叉,拉,改进 如果您正在寻找通用的免费文本自动完成,您可能想查看我的meteor自动完成软件包,它是几天前首次发布的: 你也可以从那里得到一些灵感,来做你想做的事情。我强烈推荐Meteor collection支持的实现,而不是尝试使用现有的异步库拼凑一些东西,这就是我在这里所做的。这使得autocomplete能够完全响应和客户端(列表内容可以在您查看时更新!),而且速度更快 下面的一些图片
@
自动完成用户,其中在线用户显示为绿色:
请用叉子叉,拉,改进 用问题检查此拉动请求,似乎是相同的问题。您也可以考虑使用:感谢提示,并且非常感谢您创建B3 Type先行插件,我正在查看!用问题检查此拉动请求,似乎是相同的问题。您也可以考虑使用:感谢提示,并且非常感谢您创建B3 Type先行插件,我正在查看!