Retaining selection and position in editor

2 posts, 0 answers
  1. frankju
    frankju avatar
    6 posts
    Member since:
    May 2007

    Posted 07 Feb 2008 Link to this post

    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";
            }
        }
    };
  2. Rumen
    Admin
    Rumen avatar
    12851 posts

    Posted 15 Feb 2008 Link to this post

    Hi Frank,

    I tried to reproduce the reported problem but without success. You can see my test in the attached video. Am I missing something? I provided the test with the following HTML content:

    <br /><br /><br /><br /><br /><br /><br />
        <div class="image">
    <img src="http://www.telerik.com/demos/aspnet/Prometheus/Editor/Img/productLogo.gif">
    <div>CAPTION TEXT</div>
    </div>

    Could you please open a support ticket and send your HTML content and steps to reproduce the problem so that we can replicate it on our side and try to provide a solution.

    Kind regards,
    Rumen
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

Back to Top