editor.fire - CallBack will not execute

2 posts, 0 answers
  1. Dan
    Dan avatar
    4 posts
    Member since:
    Jun 2011

    Posted 03 Jun 2011 Link to this post

    I found the following code in an existing thread (http://www.telerik.com/community/forums/aspnet/editor/set-default-image-properties-when-inserting.aspx). The editor.fire executes fine, but the callback never runs. Any suggestions?

     

    Telerik.Web.UI.Editor.CommandList["ImageDialog"] = function (commandName, editor, args) {
            function callBackFn(result) {
                if (result) {
                   var imgTag = "<img src=" + result.imagePath + " hspace='10' vspace='5' align='right' />";
                   editor.PasteHtml(imgTag);
                }
            }
            editor.fire('ImageManager' , callBackFn);
    };
  2. Dan
    Dan avatar
    4 posts
    Member since:
    Jun 2011

    Posted 06 Jun 2011 Link to this post

    For anyone that cares I came across this solution:

    function OnClientPasteHtml(sender, args) {
    var commandName = args.get_commandName();
    var value = args.get_value();
    if (commandName == "ImageManager") {
                   var div = document.createElement("DIV");
                   //Do not use div.innerHTML as in IE this would cause the image's src or the link's href to be converted to absolute path.
                   //This is a severe IE quirk.
                   Telerik.Web.UI.Editor.Utils.setElementInnerHtml(div, value);
                   //Now check if there is alt attribute
                   var img = div.firstChild;
                   img.setAttribute("align", "left");
                   img.setAttribute("hspace", "10");
                   img.setAttribute("vspace", "5");
                   args.set_value(div.innerHTML);
    }
    }
Back to Top