I'm a long time listener. I'm actually the guy that sent him that
scala question with the name "Huge G. Rection" if you remember that ;)
That crazy guy from Canada!

Anyway... I'm having a problem with JavaScript and I thought since
this community is way smarter than average communities, I might be
able to find an answer here.

If I'm using editable content divs... is there a way to easily get/set
the cursor? Gmail makes this look easy, but it's actually not an easy
problem.

My div contains text and other html elements - notably several
<span>'s. These span's indicate grammar errors and the like. So when
the person types text into the editor, we have to drop some text nodes
from the div and replace them with the spans. These spans add those
nice red squiggles and also provide tooltips indicating how to fix the
grammar error.

Every time I change the contents of the editable div, firefox will
reset the cursor to the beginning of the content box (annoying!) and
IE will reset it to the end (not as bad, but still a problem if they
edit text in the middle).

Now, I know there's selection objects and range objects. The problem
with these is that if the anchor/start nodes they were pointing to are
deleted, the browser auto-magically points them to other elements of
the DOM. In Firefox, it's the parent div container. In IE, it's
something else.

Is there another way I can save/restore selection (i.e. cursor) state?
Or do I have to wrap every word and space character with a <span> tag
just to avoid deletions?

I've spent about 6 hours on this problem, which is actually more than
it took to build the entire ajax grammar checker. I'm a little
frustrated and looking for help.

I realize this is a JavaScript question, but it's for a Java
application :)

Thanks!

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to