I'm trying to achieve the following functionality:
<div id="editor" contenteditable="true">
I am some text.
</div>
$('#editor').replaceHtmlAt(start, end, string);
Use case:
User types an
@
inside#editor
keyup
event picksup the@
position
$('#editor').replaceHtmlAt(position of @, position of @ + 1, "<div>Hello</div>");
Is this possible?
EDIT
I got it to work by doing this
$(this).slice(pos-1).html('<span id="mention'+pos+'">@</span>');
However I've encountered another problem. In Chrome, the caret position inside #editor moves all the way to the back... how do I restore the caret's position after '@' inside the span tags?