Nicolas BAILLY
Top achievements
Rank 1
Nicolas BAILLY
asked on 23 Nov 2009, 04:30 PM
Hello,
I'm trying to paste Html at the position of the cursor but it is always pasted at the begining. If I select something, my selection is deleted.
This happened when I hide and show RadEditor Control.
Here is my code :
function ShowTelerikAndPaste(text) {
editor.set_visible(true);
editor.pasteHtml(text);
}
function HideTeletik() {
editor.set_visible(false);
}
I'm trying to paste Html at the position of the cursor but it is always pasted at the begining. If I select something, my selection is deleted.
This happened when I hide and show RadEditor Control.
Here is my code :
function ShowTelerikAndPaste(text) {
editor.set_visible(true);
editor.pasteHtml(text);
}
function HideTeletik() {
editor.set_visible(false);
}
4 Answers, 1 is accepted
0
Schlurk
Top achievements
Rank 2
answered on 23 Nov 2009, 11:13 PM
I think if you take a look at combining the items discussed in this forum thread, along with the getRange documentation article you can have this functionality.
0
Nicolas BAILLY
Top achievements
Rank 1
answered on 24 Nov 2009, 02:40 PM
It doesn't work better.
I tried this :
var editor;
var range;
function ShowTelerikAndPaste(text) {
editor.set_visible(true);
if (range) {
editor.getSelection().selectRange(range);
}
editor.pasteHtml(text);
}
function HideTeletik() {
editor.set_visible(false);
range = editor.getSelection().getRange(); //returns an object that represents a restore point.
}
I tried this :
var editor;
var range;
function ShowTelerikAndPaste(text) {
editor.set_visible(true);
if (range) {
editor.getSelection().selectRange(range);
}
editor.pasteHtml(text);
}
function HideTeletik() {
editor.set_visible(false);
range = editor.getSelection().getRange(); //returns an object that represents a restore point.
}
0
Schlurk
Top achievements
Rank 2
answered on 24 Nov 2009, 10:01 PM
I think there might be an issue when you do the set_visible(false) before you grab the selection of the editor. Try to see if you can use your functions, without the visibility settings changing, and have them paste in the correct place.
0
Nicolas BAILLY
Top achievements
Rank 1
answered on 25 Nov 2009, 10:13 AM
I found a solution.
I wait before writing text in editor.
var editor;
var range;
function ShowTelerik() {
editor.set_visible(true);
if (range) {
editor.getSelection().selectRange(range);
}
}
function HideTeletik() {
editor.set_visible(false);
range = editor.getSelection().getRange(); //returns an object that represents a restore point.
}
function Paste(text) {
editor.pasteHtml(text);
}
I call ShowTelerik() first and i wait 1 second before calling Paste(text).
It works with IE and Chrome but not with Firefox. I can't find selection with Firefox.
editor.getSelection().selectRange(range); bugs. When I catch this line, I have the message error : "c is null"
I wait before writing text in editor.
var editor;
var range;
function ShowTelerik() {
editor.set_visible(true);
if (range) {
editor.getSelection().selectRange(range);
}
}
function HideTeletik() {
editor.set_visible(false);
range = editor.getSelection().getRange(); //returns an object that represents a restore point.
}
function Paste(text) {
editor.pasteHtml(text);
}
I call ShowTelerik() first and i wait 1 second before calling Paste(text).
It works with IE and Chrome but not with Firefox. I can't find selection with Firefox.
editor.getSelection().selectRange(range); bugs. When I catch this line, I have the message error : "c is null"