Hi!
I have created a context menu for img elements to provide left and right alignment options for images. I need customized functionality for this because the images are surrounded by a div element (containing a caption), and the alignment shall actually apply to the div. My problem is that after my code has run, the selection of the image is lost, and the scroll position is moved to the top. How can I retain the selection and scroll position? This is my code:
RadEditorCommandList["WCWImageLeft"] = function(commandName, editor, oTool)
{
var selection = editor.GetSelection();
var selectedElement = selection.GetParentElement();
if (selectedElement != null && selectedElement.tagName == "IMG")
{
var divElement = selectedElement.parentElement;
if (divElement != null && divElement.tagName == "DIV")
{
divElement.className = "floatLeft";
}
}
};
I have created a context menu for img elements to provide left and right alignment options for images. I need customized functionality for this because the images are surrounded by a div element (containing a caption), and the alignment shall actually apply to the div. My problem is that after my code has run, the selection of the image is lost, and the scroll position is moved to the top. How can I retain the selection and scroll position? This is my code:
RadEditorCommandList["WCWImageLeft"] = function(commandName, editor, oTool)
{
var selection = editor.GetSelection();
var selectedElement = selection.GetParentElement();
if (selectedElement != null && selectedElement.tagName == "IMG")
{
var divElement = selectedElement.parentElement;
if (divElement != null && divElement.tagName == "DIV")
{
divElement.className = "floatLeft";
}
}
};