我正在使用jquery-mentions-input来添加Mention用户的帖子。它工作正常。但是我有一个选项可以编辑帖子,我希望以前在帖子中添加的所有提及加载到textarea中,就像他们一样在添加帖子时做了。
但我无法在Textbox中以编程方式再次添加这些提及。我在数组中拥有所有UserId和userName。
我使用过这种方法,但它说addMention不存在。
$("#txteditbox").mentionsInput('addMention',userName, id, type);
答案 0 :(得分:2)
转到此链接:https://github.com/podio/jquery-mentions-input/pull/37并在此位置下载jquery.mentionsInput,其中添加了功能' addmention',因此它适用于您。
答案 1 :(得分:0)
使用json数据添加prepopulate属性
$("#txteditbox")tokenInput("controller/token.php", {
theme: "facebook",
hintText: "",
preventDuplicates: true,
tokenLimit: 5,
minChars: 2,
placeholder:"Enter tag by which anybody can search this task",
prePopulate:[
{id: 123, name: "Slurms MacKenzie"},
{id: 555, name: "Bob Hoskins"},
{id: 9000, name: "Kriss Akabusi"}
],
...........
...........