jquery autocomplete to start on pressing character '@'

﹥>﹥吖頭↗ 提交于 2019-12-06 02:55:38

I think the easiest way to do this is to provide a function to source. Something like this:

textbox.autocomplete({
    source: function (request, response) {
        var lastWord = request.term.split(/,\s*/).pop();
        if (lastWord.indexOf('@') == -1) {
            return [];
        }
        $.getJSON('YourUrl' + lastWord, {}, function (data) {
            response(values);
        });
    }
});

This will only work if the last part is the one being autocompleted though.

$('#target').keydown(function(event) {
  if (event.keyCode == 64) {
     //do something for @
   }
  if (event.keyCode == 32) {
     //do something for space
   }
});

you can see ajax samples in google -> "jquery ajax"

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!