User Mentions with knockoutjs and ajax

57 views
Skip to first unread message

MPUser One

unread,
Nov 21, 2017, 7:37:42 AM11/21/17
to KnockoutJS
We wanted to implement a user mention in a text area with ajax call to fetch the user profile from a rest service. In the service layer twitter users will be fetched using twitter api, based on the text entered after the '@' in the text area. What is the most suitable method to implement user mention in knockout js environment?

Note that our web page is implemented with knockout js 3.4 MVVM. As most articles recommend we tried with bootstrap typeahead handler for knockout js and ended up failing to update multiple user mentions. It works only once and when tried subsequently those attempts did not fetch the result via ajax for the text entered like '@<user>.

Andrew Vickers

unread,
Nov 27, 2017, 12:12:57 PM11/27/17
to KnockoutJS
Subscribe to the textarea observable with a ratelimit.  Split the string at spaces.  Find each string beginning with "@", and make your ajax calls on those substrings.  You probably want to use a cache and the fetch api (or something) so that you only make ajax requests for new/updated results.
Reply all
Reply to author
Forward
0 new messages