使用 Javascript/jQuery 更改 Telerik RadEditor 的值

2024-03-01

我正在尝试使用 Javascript 手动清理 Telerik RadEditor 的 HTML,但我似乎找不到存储该值的正确位置,以便在回发时保存该值。

这是我的JS:

$(function () {    
    jQuery.fixHash = function ($html) {      

        // modify $html

        return $html;
    };

    $("#adminEditingArea input[id$='SaveButton']").unbind("click").click(function () {
        $("iframe[id$='_contentIframe']").trigger("save");

        // call .net postback

        return false;
    });

});

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();
                    $body.html(html);

                    // also tried storing the modified HTML in the textarea, but it doesn't seem to save:
                    //$thisFrame.prev("textarea").html(encodeURIComponent("<body>" + html + "</body>"));
                }
            });
            editorSaveEventInit = true;
        }
    }
};

$(window).load(function () {
    InitSaveEvent();
});

有没有办法使用 JavaScript 访问 Telerik RadEditor 对象(使用OnClientCommandExecuted()?)这样我就可以访问.get_html() and .set_html(value)功能?如果没有,在回发之前我需要设置什么值?


你为什么不使用自定义内容过滤器 http://www.telerik.com/help/aspnet-ajax/contentfilters.html.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 Javascript/jQuery 更改 Telerik RadEditor 的值 的相关文章