This is a migrated thread and some comments may be shown as answers.

editor.fire - CallBack will not execute

1 Answer 66 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 03 Jun 2011, 08:31 PM

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);
};

1 Answer, 1 is accepted

Sort by
0
Dan
Top achievements
Rank 1
answered on 06 Jun 2011, 08:47 PM
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);
}
}
Tags
Editor
Asked by
Dan
Top achievements
Rank 1
Answers by
Dan
Top achievements
Rank 1
Share this question
or