下面的这两部分代码是怎么实现回复某人后@username中的username部分自动带链接的?我死活没看出来。。
<script type="text/javascript">
// reply a reply
function replyOne(nickname){
replyContent = $("#reply_content");
oldContent = replyContent.val();
prefix = "@" + nickname + " ";
newContent = ''
if(oldContent.length > 0){
if (oldContent != prefix) {
newContent = prefix + oldContent;
}
} else {
newContent = prefix
}
replyContent.focus();
replyContent.val(newContent);
}
</script>
——————————————————————————————————
<img src="/static/img/reply.png" align="absmiddle" border="0" alt="回复 {{ reply.member.username }}" onclick="replyOne('{{ reply.member.username }}')" class="clickable" />
<script type="text/javascript">
// reply a reply
function replyOne(nickname){
replyContent = $("#reply_content");
oldContent = replyContent.val();
prefix = "@" + nickname + " ";
newContent = ''
if(oldContent.length > 0){
if (oldContent != prefix) {
newContent = prefix + oldContent;
}
} else {
newContent = prefix
}
replyContent.focus();
replyContent.val(newContent);
}
</script>
——————————————————————————————————
<img src="/static/img/reply.png" align="absmiddle" border="0" alt="回复 {{ reply.member.username }}" onclick="replyOne('{{ reply.member.username }}')" class="clickable" />