PDA

View Full Version : HtmlEditor How-To change mode



Cocchetto
Jun 05, 2008, 1:20 PM
Hi,
how i can change mode to htmleditor with javascript?
In the Extjs API Documentation there is a public method call toggleSourceEdit
but i can't get it work!

Some suggestion?

Thanks all

geoffrey.mcgill
Jun 05, 2008, 1:25 PM
Hi Cocchetto,

Can you post the code you are using to try and change to/from source edit mode?

Cocchetto
Jun 05, 2008, 1:35 PM
<script type="text/javascript">
function test()
{
dt = Ext.get('txtDefaultValueCoolite');
dt.toggleSourceEdit(false);

...
...
}


</script>



<form id="ResxForm" runat="server" onsubmit="test();">
<cool:HtmlEditor ID="txtDefaultValueCoolite" AutoHeight="true" HideMode="Offsets" runat="server" ></cool:HtmlEditor>
</form>




I've cut the irrilevant asp.net code...

The problem is that when a user change text in source mode and click to Save Button
I can't get the text modified, only if the user change text in source mode and switch to
normal mode I get the text modified.
You can reproduce this here :

- Start writing a post in normal view
- Switch to source view
- Modify your post
- Click preview

You don't have the text modified.

geoffrey.mcgill
Jun 05, 2008, 8:56 PM
Hi Cocchetto,

Try using Ext.getCmp() instead of Ext.get().

Example


<script type="text/javascript">
function test()
{
var dt = Ext.getCmp('txtDefaultValueCoolite');
dt.toggleSourceEdit(false);
}
</script>

Or, since all the componets are instantied client-side with their ID's, you could skip the Ext.getCmp and shorten the code to the following:

Example


<script type="text/javascript">
function test()
{
txtDefaultValueCoolite.toggleSourceEdit(false);
}
</script>

Hope this helps.