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

OnBlur not firing from Html edit mode

6 Answers 226 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Sebastian P.R. Gingter
Top achievements
Rank 2
Sebastian P.R. Gingter asked on 03 May 2011, 12:53 PM
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

6 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 06 May 2011, 04:29 AM
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.

0
Sebastian P.R. Gingter
Top achievements
Rank 2
answered on 06 May 2011, 10:59 AM
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?
0
Sebastian P.R. Gingter
Top achievements
Rank 2
answered on 06 May 2011, 12:20 PM
Never mind. I used $telerik.addExternalHandler to attach the events and it works now.
0
Jim
Top achievements
Rank 1
answered on 31 Mar 2015, 07:48 PM

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");
            });

        }



0
Jim
Top achievements
Rank 1
answered on 31 Mar 2015, 07:49 PM
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
0
Ianko
Telerik team
answered on 06 Apr 2015, 02:59 AM
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.

 
Tags
Editor
Asked by
Sebastian P.R. Gingter
Top achievements
Rank 2
Answers by
Rumen
Telerik team
Sebastian P.R. Gingter
Top achievements
Rank 2
Jim
Top achievements
Rank 1
Ianko
Telerik team
Share this question
or