|
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.
|
|
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.aspxThanks!
|
|
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)
|
|
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
|
|
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.
|
|
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
|
|
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.
|
|
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!
|
|
Rank: Member Groups: Member
Joined: 11/23/2009 Posts: 27
|
ok many thanks
|
|
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?
|
|
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!
|
|
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.
|
|
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!
|
|
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!
|
|