简体   繁体   中英

Passing query parameter to backend using at.js for twitter-style-mention triggered autocomplete

I'm using at.js via:

$('#post-body').atwho(
        at:"@",
        data: "/home/mention_autocomplete",
        limit: 7
        )

I would like to pass whatever the user has typed after the '@' symbol to the backend for query and returning relevant results. Is this data accessible inside the .atwho() method?

you can use remote_filter callback.

$('#inputor').atwho({
  at: '@', 
  callbacks: {
    remote_filter: function(query, callback) {
      $.getJSON("/home/mention_autocomplete", {q: 'whatever'}, function(data) {
        callback(data.usernames);
      });
    }
  }
});

ref: https://github.com/ichord/At.js/wiki

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM