Changing the value of a Telerik RadEditor with Javascript/jQuery

大兔子大兔子 提交于 2019-12-06 07:21:35

Why don't you use custom content filters.

Ah, just discovered Telerik's built-in $find() function: http://www.telerik.com/help/aspnet-ajax/editor_getingreferencetoradeditor.html

Edit: here's the solution I came up with for my InitSaveEvent() function:

var editorSaveEventInit = false;
function InitSaveEvent() {
    if (!editorSaveEventInit) {
        var $EditFrames = $("iframe[id$='_contentIframe']");
        if ($EditFrames && $EditFrames.length > 0) {
            $EditFrames.bind("save", function (e) {
                var $thisFrame = $(this);
                var thisFrameContents = $thisFrame.contents();
                if (thisFrameContents) {
                    var telerikContentIFrame = thisFrameContents.get(0);
                    var $body = $("body", telerikContentIFrame);
                    var html = $.fixHash($body).html();
                    // SOLUTION!
                    var $radeditor = $thisFrame.parents("div.RadEditor.Telerik:eq(0)");
                    var editor = $find($radeditor.attr("id"));
                    editor.set_html(html);
                    // ☺
                }
            });
            editorSaveEventInit = true;
        }
    }
};
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!