This is a migrated thread and some comments may be shown as answers.

Wrong focus

2 Answers 90 Views
Editor
This is a migrated thread and some comments may be shown as answers.
sohrab
Top achievements
Rank 1
sohrab asked on 20 Aug 2008, 11:09 AM
How can I set the focus onto the texteditor of the editor. The old Editor from Q2 2007 had an autofocus option which worked perfectly but cannot be adapted to the latest version of the Radeditor.
Radeditor1.Focus() in the preRender didnt work.

in Javascript

var

focussedEditor = $find("<%=Radeditor1.ClientID %>");

focussedEditor.setFocus();

Kind of worked but it sets the entire editor into focus and not exclusively the textfield.

What I would like to achieve is that when the editor is loaded the cursor would be in the textfield and the user can start typing instantly.

2 Answers, 1 is accepted

Sort by
0
Accepted
Rumen
Telerik team
answered on 20 Aug 2008, 12:08 PM
Hello Sohrab,

Here is the requested example:

<telerik:radeditor runat="server" ID="RadEditor1" OnClientLoad="SetFocusOnRadEditor">

</telerik:radeditor>
<script type="text/javascript">
   function SetFocusOnRadEditor(editor, args)
   {
       setTimeout(function()
       {
        editor.setFocus(); //set the focus on the the editor
       }, 200);
   }
</script>

By firing the setFocus method a little after the full editor's load you will be able to set the focus in the content area.

You can also try editor.get_document().body.focus(); .

Kind regards,
Rumen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
sohrab
Top achievements
Rank 1
answered on 20 Aug 2008, 12:20 PM
***EDIT***

Hello Rumen,

it is working now. The reason why my attempts weren't working before is that I forgot that I've set the EditMode to "Preview". In this case designing the content is not possible hence I cant see the cursor in the editor.

Apologies for wasting your time :)
Tags
Editor
Asked by
sohrab
Top achievements
Rank 1
Answers by
Rumen
Telerik team
sohrab
Top achievements
Rank 1
Share this question
or