[英]jquery autocomplete for keypress event
I create comment box like a facebook comment box. 我创建评论框,就像Facebook的评论框一样。 I have to do like this in textarea box type @ sign and after I type letter then detect this letter or letters and popup friend list.
我必须在textarea框内输入@符号,然后输入字母,然后检测到该字母或字母,然后弹出朋友列表。
$("textarea#event_message").autocomplete("friendsAutoComplete");
this method used for autocomplete that works fine. 这种用于自动完成的方法效果很好。 but want this method fire after type @ sign.
但要在键入@符号后触发此方法。
I tried this way 我这样尝试
$('textarea#event_message').keypress(function(event) {
if(event.which == 64) {
$('textarea#event_message').autocomplete("friendsAutoComplete");
}
});
and I also tried jquery live method 我也尝试了jQuery live方法
It doesn't like work.How can I solve that problem? 它不喜欢工作,如何解决这个问题?
First of all, what is the string "friendsAutoComplete" you referring? 首先,您指的是字符串“ friendsAutoComplete”?
To fire a search using an initialized autocomplete
widget, you should call the search method instead. 要使用初始化的
autocomplete
窗口小部件触发搜索,您应该改为调用search方法。
http://jqueryui.com/demos/autocomplete/ http://jqueryui.com/demos/autocomplete/
So you may try out 所以你可以试试
$('textarea#event_message').keypress(function(event) {
if(event.which == 64) {
$('textarea#event_message').autocomplete("search");
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.