Set focus to RTE?

2 posts, 0 answers
  1. Alex Lee
    Alex Lee avatar
    4 posts
    Member since:
    Dec 2009

    Posted 16 Sep 2010 Link to this post

    Hi folks,

    I have a page in SharePoint 2007 that contains a number of fields, including a Rich Text Editor field that is using the Telerik version in place of the original Microsoft one.

    I'm doing a little bit page manipulation using jQuery - making another field on the (SharePoint created/rendered) page disabled. The result of doing this is that the Telerik RTE loses the focus - i.e. no blinking cursor, and the user is required to click within the RTE frame in order to start typing.

    What I would really like to do is set the focus back to the RTE so no click is necessary. I've tried using some jQuery calls to get the <iframe> with class "RadEContentBordered", which has a tag <body contentEditable="true"> and setting the focus on one of these elements, or the <div> within the <body>, but so far, no luck.
    e.g.
    $(".RadEContentBordered").focus();
    $("body[contentEditable=true]").focus();
    $("body[contentEditable=true] div").focus();

    Can anyone at Telerik help?? Perhaps there's a Telerik JavaScript object that I can use - call a method to set the focus?

    Thanks...
    Alex
  2. Alex Lee
    Alex Lee avatar
    4 posts
    Member since:
    Dec 2009

    Posted 16 Sep 2010 Link to this post

    OK, I've managed to answer my own question. It's the normal way, I find: ask Support a question and whilst waiting for their answer, a little more digging seems to uncover what you needed. Thanks in this case go to the IE8 Developer Tools allowing me to look at all the JS loaded, and searching through them for "focus"......... and then working out which object the function had been created in!

    For me, all I needed was this line of JavaScript:
    RadEditorGlobalArray[0].SetFocus();

    Maybe it will help someone else...
    Alex

Back to Top