I've created a custom ribbon button where i load external content into a Modal Dialog. I want to insert some text on the editor and close the dialog. The function OnPopClosed is running when I click something on my dialog but I'm having an error: RTE is not defined, so I can't insert anything on the editor. Any ideas?
function init(){
var options = SP.UI.$create_DialogOptions();
options.title = "Sharepoint Plugin";
options.width = 600;
options.height = 400;
options.url = '/_Layouts/Test/Test.aspx';
options.dialogReturnValueCallback = OnPopClosed;
SP.UI.ModalDialog.showModalDialog(options);
}
function OnPopClosed(test) {
var range = RTE.Cursor.get_range();
range.deleteContent();
var selection = range.parentElement();
if (!selection) {
return;
}
range.insertNode(elem);
RTE.Cursor.get_range().moveToNode("test");
RTE.Cursor.update();
SP.UI.ModalDialog.commonModalDialogClose(1, "test");
}
Place RTE actions in SP.SOD.executeOrDelayUntilScriptLoaded in order to execute the specified function if the file containing it is loaded (in your case
sp.ui.rte.js
):Example:
then declare the dialog handler like this: