Welcome Guest Search | Active Topics | Sign In | Register

getSelection in Editor Options
Stephen Kemsley
Posted: Friday, December 11, 2009 12:18:10 PM
Rank: Member
Groups: Member

Joined: 11/23/2009
Posts: 27
Hello,
Hopefully and easy one to answer.

I understand I can use the getSelection javascript method to get the selected html (or cursor position?) from the editor contents.
I'd then like to change this selection and replace the editor content. Do I use the setHtml method for this?

The idea is, I'll have a droplist of non standard keyboard html characters, e.g. bullet, copyright etc. which on selection from the droplist should drop in at the selected position in the editor contents.

I can invoke the javascript on the droplist selection and get the selected character, and can get the selected html content, but how do I replace the selected content and update the content?

Many thanks
s.
eo_support
Posted: Friday, December 11, 2009 1:32:49 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

You won't be able to get/set cursor position. However you can use getSelection to get the current selected text and calling execCommand with "InsertHTML" command to insert any text into the editor. If there is selection, it will replace the selection, otherwise it inserts the text. Please see here for more details:

http://doc.essentialobjects.com/library/1/jsdoc.public.editor.execcommand.aspx

Thanks
Stephen Kemsley
Posted: Tuesday, December 15, 2009 9:50:48 AM
Rank: Member
Groups: Member

Joined: 11/23/2009
Posts: 27
Many thanks, I'm now able to insert html within the editor contents.

Now next, I'd like to be able to replace all of the html content. Should setHtml do this?
I'm doing the following in javascript;

varOText = document.getElementById("HiddenText").value;
var editor = eo_GetObject("TextBoxEditor");
editor.setHtml = varOText;

where "HiddenText" is an asp:textbox with the text to replace the editor contents with and "TextBoxEditor" is the eo:editor to replace.

Am I missing something from the setHtml?

Thanks.
eo_support
Posted: Tuesday, December 15, 2009 1:21:03 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi,

setHtml is a function. So you would call it as a function, not to set it as a property.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.