
Sean Murphy
Top achievements
Rank 1
Sean Murphy
asked on 24 Jan 2008, 05:29 PM
Hi, I am trying to use an external source to populate content at the last place the cursor existed before leaving the editor. From the resources I could find, it seemed this would do the trick:
function OnClientLoad(editor){
alert('I can get this far...');
editor.AttachEventHandler ("onblur", function (e){
restorePoint = editor.createRestorePoint();
alert('but not here...');
});
}
Unfortunately, although I don't get errors, nothing happened when I focus and then leave the editor. I then tried the following:
function OnClientLoad(editor, args){
alert('I can get this far...');
Telerik.Web.DomElement.addExternalHandler(editor, "onblur", function(e)
{
restorePoint = editor.createRestorePoint();
alert('but not here...');
});
}
Still no luck. Can you point me in the right direction? If it helps to know, I am trying to place a link in the body of the radtreeeditor from an external radtreeview of directories, but cannot get the restore point.
function OnClientLoad(editor){
alert('I can get this far...');
editor.AttachEventHandler ("onblur", function (e){
restorePoint = editor.createRestorePoint();
alert('but not here...');
});
}
Unfortunately, although I don't get errors, nothing happened when I focus and then leave the editor. I then tried the following:
function OnClientLoad(editor, args){
alert('I can get this far...');
Telerik.Web.DomElement.addExternalHandler(editor, "onblur", function(e)
{
restorePoint = editor.createRestorePoint();
alert('but not here...');
});
}
Still no luck. Can you point me in the right direction? If it helps to know, I am trying to place a link in the body of the radtreeeditor from an external radtreeview of directories, but cannot get the restore point.
8 Answers, 1 is accepted
0
Hi Sean,
Here is how to attach the blur method to the editor's content area:
<script type="text/javascript">
function OnClientLoad(editor, args)
{
alert('I can get this far...');
Telerik.Web.DomElement.addExternalHandler(editor.get_document().body, "blur", function(e)
{
restorePoint = editor.createRestorePoint();
alert('but not here...');
});
}
</script>
<telerik:radeditor runat="server" OnClientLoad="OnClientLoad" ID="RadEditor1"></telerik:radeditor>
Greetings,
Rumen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Here is how to attach the blur method to the editor's content area:
<script type="text/javascript">
function OnClientLoad(editor, args)
{
alert('I can get this far...');
Telerik.Web.DomElement.addExternalHandler(editor.get_document().body, "blur", function(e)
{
restorePoint = editor.createRestorePoint();
alert('but not here...');
});
}
</script>
<telerik:radeditor runat="server" OnClientLoad="OnClientLoad" ID="RadEditor1"></telerik:radeditor>
Greetings,
Rumen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

Peter Blum
Top achievements
Rank 1
answered on 27 Jan 2008, 06:13 PM
Just a follow-up. I also need this capability to get my validators (from "Peter's Data Entry Suite") to work. (Actually, I'd prefer an onchange event but I'll take this.)
I had used onblur capability in the previous RadEditor product.
The posted answer does work, although its not very clean. I encourage you to make this, and events like onfocus and onchange, first class citizens of your product's support.
onfocus and onblur are very useful in so many situations, like showing a help hint as the user enters the field. (Merely an example as I know you have RadHints).
--- Peter
I had used onblur capability in the previous RadEditor product.
The posted answer does work, although its not very clean. I encourage you to make this, and events like onfocus and onchange, first class citizens of your product's support.
onfocus and onblur are very useful in so many situations, like showing a help hint as the user enters the field. (Merely an example as I know you have RadHints).
--- Peter
0

Peter Blum
Top achievements
Rank 1
answered on 27 Jan 2008, 06:37 PM
I spoke too soon. I was not able to get the posted solution to work within FireFox. Is there a solution for FireFox and other browsers?
--- Peter
--- Peter
0
Hi Peter,
Here is a solution for both IE and FF browsers:
<script type="text/javascript">
function OnClientLoad(editor, args)
{
alert('I can get this far...');
var element = document.all ? editor.get_document().body : editor.get_document();
Telerik.Web.DomElement.addExternalHandler(element, "blur", function(e)
{
restorePoint = editor.createRestorePoint();
alert('but not here...');
});
}
</script>
<telerik:radeditor runat="server" OnClientLoad="OnClientLoad" ID="RadEditor2"></telerik:radeditor>
If the used browser is Internet Explorer attach the event to the editor's Document body else if the browser is Firefox attach the event to the editor's Document.
Best regards,
Rumen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Here is a solution for both IE and FF browsers:
<script type="text/javascript">
function OnClientLoad(editor, args)
{
alert('I can get this far...');
var element = document.all ? editor.get_document().body : editor.get_document();
Telerik.Web.DomElement.addExternalHandler(element, "blur", function(e)
{
restorePoint = editor.createRestorePoint();
alert('but not here...');
});
}
</script>
<telerik:radeditor runat="server" OnClientLoad="OnClientLoad" ID="RadEditor2"></telerik:radeditor>
If the used browser is Internet Explorer attach the event to the editor's Document body else if the browser is Firefox attach the event to the editor's Document.
Best regards,
Rumen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

Rob
Top achievements
Rank 1
answered on 25 Mar 2008, 11:43 AM
Just adding an update to this as the code for this has changed and it might help anyone else who comes across this thread in the future wonder why their code isnt working as expected.
The way of attaching a handler has changed and to make it work "Telerik.Web.DomElement.addExternalHandler" needs replacing with "$telerik.addExternalHandler".
Rob
The way of attaching a handler has changed and to make it work "Telerik.Web.DomElement.addExternalHandler" needs replacing with "$telerik.addExternalHandler".
Rob
0

mfleischauer
Top achievements
Rank 1
answered on 05 Mar 2009, 02:11 AM
I just ran into this exact problem and your code suggestion worked perfectly
var element = document.all ? editor.get_document().body : editor.get_document();
$telerik.addExternalHandler(element, "blur", function(e) {
alert("here");
});
Now it works perfectly in Firefox, IE and Opera, but fails in the Webkit ( Chrome & Safari 4 ) based browsers. I am using Rad AJAX Q2.
Any suggestions appreciated.
0
Hi Mike,
The reported behavior is clearly bug in Safari - because it expects that the third argument of the addEventListener function to be true - but this is completely wrong.
Nevertheless, to attach the blur event in Safari / Chrome use the following code:
var element = editor.get_document();
element.addEventListener('blur', handleEvent, true);
function handleEvent() { alert("Safari"); }
Best regards,
Rumen
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
The reported behavior is clearly bug in Safari - because it expects that the third argument of the addEventListener function to be true - but this is completely wrong.
Nevertheless, to attach the blur event in Safari / Chrome use the following code:
var element = editor.get_document();
element.addEventListener('blur', handleEvent, true);
function handleEvent() { alert("Safari"); }
Best regards,
Rumen
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0

mfleischauer
Top achievements
Rank 1
answered on 05 Mar 2009, 03:36 PM
Excellent, thanks very much.