I've searched for the solution for this everywhere and have not found an answer, so you're my last hope, Stackoverflow...
With regard to cleditor, does anybody know how to make the "inserthtml" command in "View Source" mode work?
Currently, I have a method attached to a button's onclick handler that inserts a string into the cleditor's textarea:
editor.focus();
setTimeout(function() { editor.execCommand('inserthtml', stringToInsert); }, 0);
The above works fine in the normal Rich Text mode but if you try to execute it while in View Source mode, the following will happen:
hi i think it is very simmilar problem as here
i assume that code pasted by you is executed in button click function at the end of this function just add
return false;
add sopmething like that:
function someClick(e, data) {
// Get the editor
var editor = data.editor;
editor.focus();
setTimeout(function() { editor.execCommand('inserthtml', stringToInsert); }, 0);
return false;
}
edit:
yep you are right it is not so easy : when yo are in normal mode your text area is actualy iframe when you are in source mode your textarea is again becomeing textarea so to edit data inside you can get it by
$('#mytextarea').val()
if you want to append something at the end you can use :
setTimeout(function() {$('#mytextarea').val($('#mytextarea').val()+'aaaaa') }, 3000);
if you want to insert at current ursor cosition this should help : Cursor position in a textarea (character index, not x/y coordinates)