Welcome Guest Search | Active Topics | Sign In | Register

editor value in javascript Options
Stephen Kemsley
Posted: Monday, November 23, 2009 10:32:24 AM
Rank: Member
Groups: Member

Joined: 11/23/2009
Posts: 27
Hi there,
Question regarding picking up the html value of an editor control via javascript.

If document.getElementById("EditTextTextBoxEditor").value; gets the value of a textbox, whats the equivilent for an Editor?

Many thanks.
eo_support
Posted: Monday, November 23, 2009 10:39:43 AM
Rank: Administration
Groups: Administration

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

You will need to get an instance of our editor with eo_GetObject first, then call getHtml on that object to retrieve the HTML contents. Please see here for more details about how to use our client side JavaScript interface:

http://doc.essentialobjects.com/library/1/clientapi_howto.aspx

Thanks!
Stephen Kemsley
Posted: Monday, November 23, 2009 11:53:53 AM
Rank: Member
Groups: Member

Joined: 11/23/2009
Posts: 27
Many thanks, I have that code in place and still experiencing problems.

I am setting up my variables as follows;
var TextCheckHiddenFieldVar = document.getElementById("EditTextTextBox").value;
var editor = eo_GetObject("EditTextTextBoxEditor");
var HTMLText = editor.getHtml();

On checking them via an alert the values are identical;
window.alert(HTMLText);
window.alert(TextCheckHiddenFieldVar);

However when comparing one to other via the following if statement, this statement results as true.
if(TextCheckHiddenFieldVar != HTMLText)
eo_support
Posted: Monday, November 23, 2009 12:05:31 PM
Rank: Administration
Groups: Administration

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

The two will surely not the same. In fact you can not use document.getElementById with the editor. It's not a simple textbox so you should not treat it as such. You should always use eo_GetObject and getHtml.

Thanks
Stephen Kemsley
Posted: Monday, November 23, 2009 12:15:35 PM
Rank: Member
Groups: Member

Joined: 11/23/2009
Posts: 27
var TextCheckHiddenFieldVar = document.getElementById("EditTextTextBox").value;

EditTextTextBox is an asp.net:textbox control.

I'm trying to compare the value of a textbox to that of the html editor control.
eo_support
Posted: Monday, November 23, 2009 12:22:33 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
I see. Sorry about not noticing the difference. However I am still not sure why the two are related, particular why check the text in the textbox is the same as the text in the editor (or why they should be the same)? They won't be the same even if you give them the same value because the Editor formats the HTML (for example, it adds indents).

Thanks
Stephen Kemsley
Posted: Monday, November 23, 2009 3:06:39 PM
Rank: Member
Groups: Member

Joined: 11/23/2009
Posts: 27
I'm using a textbox for visual debugging, in reality it should use a hidden arg. The idea is to check on whether the text in the html has changed (and if so invoke further code procedures) by comparing it to the orginal which is placed in the hidden arg ( or in this case textbox). If you've an idea of a better on how to test this I'd be very grateful.

Thanks.
eo_support
Posted: Monday, November 23, 2009 3:59:35 PM
Rank: Administration
Groups: Administration

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

The easiest way is for you to handle ClientSideOnChange event with JavaScript. Inside that event you will set a hidden field's value (for example, set it to "1"). You would then check that value on server side to determine whether the editor contents has changed. There is no easy way to detect changes based comparision because the editor always try to "clean up" the HTML. For example, if you give it "<B>test" and you will get back "<b>test</b>" even though user has not made any changes.

Thanks!
Stephen Kemsley
Posted: Monday, November 23, 2009 4:23:27 PM
Rank: Member
Groups: Member

Joined: 11/23/2009
Posts: 27
ok many thanks
Stephen Kemsley
Posted: Tuesday, November 24, 2009 12:25:38 PM
Rank: Member
Groups: Member

Joined: 11/23/2009
Posts: 27
Is there any way I can invoke an event when the user types in the eo:editor? In addition to the above I'd like to show a real time character count. When using an asp:textbox I can use the onkeyup event to invoke a javascript to perform the count. Is there something similar I can do with the editor?
eo_support
Posted: Tuesday, November 24, 2009 12:46:45 PM
Rank: Administration
Groups: Administration

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

It will still be the same ClientSideOnChange event. Please note this event is not real time. It may be fired with a slight delay so that it doesn't get fired too frequently.

Thanks!
Stephen Kemsley
Posted: Wednesday, November 25, 2009 5:20:08 AM
Rank: Member
Groups: Member

Joined: 11/23/2009
Posts: 27
It's close, the event fires when typing in Design mode but not when in html mode. It also doesn't fire when applying formatting e.g. bold when in design mode.
eo_support
Posted: Wednesday, November 25, 2009 7:22:59 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
That should be a bug. We will look into it and see if we can fix it as soon as possible.

Thanks!
eo_support
Posted: Friday, November 27, 2009 9:21:20 AM
Rank: Administration
Groups: Administration

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

We have posted a new build (2009.0.39) that should fix this problem. Please see your private message for the download location.

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.