返回介绍

Insert the `at` or not

发布于 2019-05-19 12:50:02 字数 1893 浏览 1167 评论 0 收藏 0

PS. All blocks in this article like this word would be an option in settings

Somebody want to insert the at into inputor(textarea/contentEditable), but somebody don't.
So, maybe I can just add an optional setting, But i think there is a better way: using the tpl.

First, After v0.4.0, At.js will not insert the at anymore. But the default tpl will do it instead!
So, If you have to customize tpl or inserted_tpl and want to insert the at as well, You have to do it yourself.

Textarea

Now At.js will just insert the data-value in tpl, so you can just put the at into it or remove it:

// for {at: "@"} and don't insert it.
<li data-value='${name}'>${name}</li>

// for emojis {at: ":"} and insert it.
<li data-value=':${name}:'>${name}</li>

In default tpl: <li data-value='${atwho-at}${name}'>${name}</li>, The variable: atwho-at would just be the current at. you can use it if you like. ;)

ContentEditable Mode

In contentEditable mode, At.js will just insert data-value in tpl by default too.
so if you want to customize inserted_tpl, choose to insert the at or not by yourself. For example:

// Default inserted_tpl:
<span>${atwho-data-value}</span>

// Customize and Don't insert `at`:
<div>${name}<span class="large">${title}</span></div>

// Customize and insert `at`:
<div><span class="at-class">@</span><span class="user-name">${name}</span></div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文