Tag-like autocompletion and caret/cursor movement in contenteditable elements.

Posted by jimeh on Stack Overflow See other posts from Stack Overflow or by jimeh
Published on 2010-05-09T15:34:58Z Indexed on 2010/05/09 15:38 UTC
Read the original article Hit count: 282

Filed under:
|
|

I'm working on a jQuery plugin that will allow you to do @username style tags, like Facebook does in their status update input box.

My problem is, that even after hours of researching and experimenting, it seems REALLY hard to simply move the caret. I've managed to inject the <a> tag with someone's name, but placing the caret after it seems like rocket science, specially if it's supposed work in all browsers.

And I haven't even looked into replacing the typed @username text with the tag yet, rather than just injecting it as I'm doing right now... lol

There's a ton of questions about working with contenteditable here on Stack Overflow, and I think I've read all of them, but they don't really cover properly what I need. So any more information anyone can provide would be great :)

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about contenteditable