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

Accessing Content Element of Editor

3 Answers 54 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Rashim
Top achievements
Rank 1
Rashim asked on 19 Sep 2011, 07:14 PM
Hi ,
I want to access a div inside the content of the editor. What i have done is given below.

<telerik:RadEditor runat="server" ID="RadEditor1">
        <Tools>
            <telerik:EditorToolGroup>
                <telerik:EditorTool Name="DragAndDropContainer" Text="Drag and Drop a div"  />                 
            </telerik:EditorToolGroup>
        </Tools>
        <Content>
            <div id="dragable1" style="position: relative; width: 50px; height: 50px; background: none repeat scroll 0% 0% silver;
            border: 1px dashed red; left: 294px; top: 3px;" >
        </div>
        </Content>
    </telerik:RadEditor>

<script type="text/javascript">
        //<![CDATA[
        Telerik.Web.UI.Editor.CommandList["DragAndDropContainer"] = function(commandName, editor, args)
        {
            if (editor.getSelectionHtml() != "")
            {
                editor.fire("FontSize", {value : "4"}); //fire the FontSize command
                editor.fire("ForeColor", {value : "red"}); //fire the ForeColor command
            }
            else
            {         
            DragHandler.attach(document.getElementById('dragable1'));            
            }
        };

In this case document.getElementById('dragable1') returns null. Could anyone help how should i access this div.

Thanks,
Rashim

3 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 21 Sep 2011, 06:54 AM
Hello Rashim,

Try setting the ContentAreaMode property of RadEditor to DIV, so that the content area becomes part of the current page.
In the other case the content area will be iframe which is another document and DragHandler function will be not accessible in it. You can access elements in the iframe content area using editor.get_document().body client method.


Best wishes,
Rumen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Rashim
Top achievements
Rank 1
answered on 22 Sep 2011, 03:12 PM
Yeah that's fine. But if i set the ContentAreaMode property of RadEditor to DIV the div element inside the content area I could not re-size it.
Could you please help me in this regard

Thanks,
Rashim
0
Rumen
Telerik team
answered on 23 Sep 2011, 11:37 AM
Hi Rashim,

When the content area is rendered as an editable div, then the absolutely positioned div element in it can be resized only in IE. This feature is offered in IE only when the ContentAreaMode property is set to DIV.

Best regards,
Rumen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Editor
Asked by
Rashim
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Rashim
Top achievements
Rank 1
Share this question
or