OnBlur not firing from Html edit mode

7 posts, 0 answers
  1. Sebastian P.R. Gingter
    Sebastian P.R. Gingter avatar
    7 posts
    Member since:
    Jun 2010

    Posted 03 May 2011 Link to this post

    Hi,

    I'm attaching the onBlur event of the RadEditor in this way:
    var element = document.all ? editor.get_document().body : editor.get_document();
    $telerik.addExternalHandler(element, "blur", this._onBlurDelegate);

    This is working fine in wysiwyg edit mode but not when the Editor is switched to the HTML editor mode.
    How can I react to the onBlur event also if the editor is set to html edit mode and the html editor is losing focus?

    Regards,

       Sebastian
  2. Rumen
    Admin
    Rumen avatar
    12848 posts

    Posted 05 May 2011 Link to this post

    Hi Sebastian,

    You can see how to attach to events to the HTML mode's TextArea of RadEditor in the following forum thread:

    http://www.telerik.com/community/forums/aspnet-ajax/editor/tabbing-in-html-mode.aspx,
    http://www.telerik.com/community/forums/aspnet-ajax/editor/eventhandler-for-html-area.aspx
    and
    http://www.telerik.com/community/forums/aspnet-ajax/chart/charector-limit-in-rad-editor.aspx

    All the best,
    Rumen
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sebastian P.R. Gingter
    Sebastian P.R. Gingter avatar
    7 posts
    Member since:
    Jun 2010

    Posted 06 May 2011 Link to this post

    Hi Rumen,

    thanks for the response. But all three samples you linked to use this pattern:

    var textArea = sender.get_textArea();
    textArea.attachEvent("eventName", eventHander);

    The problem is, that, even in the modeChange event of the editor and when the new mode is 2, the textArea does not have a function 'attachEvent'.

    For instance I get this error message: "htmlEditor.attachEvent is not a function: htmlEditor.attachEvent("blur", _onBlurDelegate); "
    where htmlEditor is the result of sender.get_TextArea() in the modeChange event of the editor and it is the correct editor element.

    So what goes wrong here?
  5. Sebastian P.R. Gingter
    Sebastian P.R. Gingter avatar
    7 posts
    Member since:
    Jun 2010

    Posted 06 May 2011 Link to this post

    Never mind. I used $telerik.addExternalHandler to attach the events and it works now.
  6. Jim
    Jim avatar
    14 posts
    Member since:
    Aug 2013

    Posted 31 Mar 2015 in reply to Sebastian P.R. Gingter Link to this post


    function OnClientLoad(editor, args) {
         editor.set_mode(2);
         var element = document.all ? editor.get_document().body : editor.get_document();
         $telerik.addExternalHandler(element, "blur", function (e) {            
            alert("RadEditor lost focus");
         });
         editor.attachEventHandler("blur", function (e) {
            alert("Blur fired");
         });
    }
          function OnClientLoad(editor, args) {
                editor.set_mode(2);

                var element = document.all ? editor.get_document().body : editor.get_document();
                $telerik.addExternalHandler(element, "blur", function (e) {            
                    alert("RadEditor lost focus");
                });

                editor.attachEventHandler("blur", function (e) {
                    alert("Blur fired");
                });

            }



  7. Jim
    Jim avatar
    14 posts
    Member since:
    Aug 2013

    Posted 31 Mar 2015 Link to this post

    Sorry for some reason my post got messed up.
    The code I posted works when in "Design" mode but not "HTML" mode.

    Can  you please post the code that works for you?

    Thanks,
    Jim
  8. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 05 Apr 2015 Link to this post

    Hello Jim,

    Note that the code snippet provided by Rumen showcases attaching a handler to the textarea. In the examples sent by you, the handler is attached only to the body element (i.e., the content area), and thus the handler is attached only to the Design mode and not to the textarea.

    Regards,
    Ianko
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017