Problem with focus and radeditor

7 posts, 0 answers
  1. ericc34
    ericc34 avatar
    91 posts
    Member since:
    Jul 2006

    Posted 09 Sep 2011 Link to this post

    I have a page in which i have a panel. In this panel, i load controls (text box) dynamically. And under this panel I have a radeditor. When user change an textbox field, i change content of my radeditor like this :

    function ChangeTextEditorFieldValue(sender, args) {
    ar elem = sender.get_element();


    var attributedElem = document.getElementById( + '_text');


    var fieldName = attributedElem.getAttribute('fieldCode');

    var oldValue = args.get_oldValue();
    var newValue = args.get_newValue();

    var editor = GetFormEditor();

    if (!oldValue) {
      var newhtml = ReplaceAll(editor.get_html(true), "{" + fieldName + "}", "[" + newValue + "]");

    When i do this, RadEditor got focus but I want to set focus to ELEM (textbox i've change) like this :


    but focus stay on radeditor. Why ??? I'm on IE9

  2. Rumen
    Rumen avatar
    13246 posts

    Posted 13 Sep 2011 Link to this post

    Hi Ericc34,

    The set_html() method sets the focus in RadEditor to set the content.

    You can try two different approaches to fix the problem:

    1) Set the content in RadEditor using
         editor.get_document().body.innerHTML = newhtml;

    2) or set the focus on the textbox after a small delay, e.g.

    }, 100);

    Kind regards,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. ericc34
    ericc34 avatar
    91 posts
    Member since:
    Jul 2006

    Posted 26 Sep 2011 Link to this post

    Theses 2 solutions don't work, in first solution, all the document (page) are set to newhtml not only radeditor content and in second solution, radeditor keep focus
  4. ATS
    ATS avatar
    49 posts
    Member since:
    Mar 2007

    Posted 29 Nov 2011 Link to this post

    Same here. The first option does work, but the content in the editor doesn't refresh. So while I can verify the change was made by calling alert(editor.get_document().body.innerHtml); at the end of my javascript call, that doesn't help me much if the user can't see the change.

    And similarly, the timeout/focus option does not change the focus from the editor either.

    Is there no way to hand focus back after you've updated the content? I'm not sure I understand why we have to jump through hoops to get the focus back.

  5. ATS
    ATS avatar
    49 posts
    Member since:
    Mar 2007

    Posted 29 Nov 2011 Link to this post

    Argh - I spoke too soon!

    The editor.get_document().body.innerHTML = newhtml; method works perfectly. Provided you use innerHTML, not innerHtml :-)

    I still think we shouldn't have to jump through the hoops, but at least it's an easy workaround ;-)

    Thanks Rumen!
  6. Chad
    Chad avatar
    8 posts
    Member since:
    Feb 2014

    Posted 14 May 2014 Link to this post

    How do I do this with JavaScript / JQuery?
  7. Ianko
    Ianko avatar
    1738 posts

    Posted 15 May 2014 Link to this post

    Hello Chad,

    The discussed matter in this forum thread is entirely about client-side approaches and the mentioned editor.get_document().body.innerHTML = newhtml; line of code is written with JavaScript.


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top