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

[Solved] Editor in window and modal dialogs

2 Answers 133 Views
Editor
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jozef
Top achievements
Rank 1
Jozef asked on 18 Apr 2011, 09:38 AM

Hi,

I'm using Editor in Window (which is in modal mode). When I open new modal window from editor - e.g. Insert image, underlying modal window is still active (I have there two buttons - save and cancel) and it is possible to close underlying modal dialog with actual editor, while Insert image dialog is active. I tried to solve it by attaching client-side event when opening Insert image dialog to disable temporarily close buttons, with no success. It looks it has problem with attaching client events when it is nested into window.

Thank you for suggestions.

Jozef

2 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 21 Apr 2011, 01:29 PM
Hello Jozef,

Thank you for notifying us of this problem. Since the editor window does not fire events that can be captured, a work-around would be to decrease the z-index of the parent window. The following hack should do the job (this is a modified version of the popup form example):
    <%  Html.Telerik().Window()
        .Name("Window")
        .Title("Submit feedback")
        .Content(() => {%>
            <% using (Html.BeginForm("popupform", "window", FormMethod.Post, new { id = "feedback-form" }))
               { %>
                    <p class="note">This is just an example, sent data will <strong>not</strong> be saved.</p>
 
                    <label for="name">Name:</label>
                    <%= Html.TextBox("name") %>
 
                    <label for="email">E-mail:</label>
                    <%= Html.TextBox("email") %>
 
                    <label for="comment-value">Comments:</label>
                    <%= Html.Telerik().Editor()
                            .Name("comment")
                            .Tools(tools => tools
                                .Clear()
                                .Bold().Italic().Separator()
                                .InsertOrderedList().InsertUnorderedList().Separator()
                                .Indent().Outdent()
                                .CreateLink().InsertImage()
                            )%>
 
                    <div class="form-actions">
                        <button type="submit" class="t-button">Submit feedback!</button>
                    </div>
 
            <% } %>
        <%})
        .Width(400)
        .Draggable(true)
        .Modal(true)
        .Visible(false)
        .Render();
%>
 
<button id="feedback-open-button" class="t-button">Submit feedback...</button>
 
<% Html.Telerik().ScriptRegistrar()
    .OnDocumentReady(() =>
    {%>
        // open the initially hidden window when the button is clicked
        $('#feedback-open-button')
            .click(function(e) {
                e.preventDefault();
                $('#Window').data('tWindow').center().open();
            });
 
        var editor = $('#comment').data('tEditor'),
            oldExec = editor.exec;
 
        // capture calls to the 'exec' command of the editor
        editor.exec = function(name, params) {
            if (name == "createLink" || name == "insertImage") {
                // move parent window behind
                $('#Window').css('z-index', 9000);
 
                function restore() {
                    $('#Window').css('z-index', '');
                    $(editor.element).unbind('selectionChange', arguments.callee);
                    $(document.documentElement).undelegate(".t-close,.t-dialog-close", 'click', arguments.callee);
                }
 
                // restore z-index when command finishes
                $(editor.element).bind('selectionChange', restore);
                $(document.documentElement).delegate(".t-close,.t-dialog-close", "click", restore);
            }
 
            // delegate call to default exec function
            oldExec.call(editor, name, params);
        };
    <%}); %>

I have logged the issue to the issue tracking system.

Regards,
Alex Gyoshev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jozef
Top achievements
Rank 1
answered on 21 Apr 2011, 01:41 PM

Hello Alex,

thank you for your long post. In meantime I was able to find another workaround = hook to editor's event OnExecute and if it is action opening new window (hyperlink/image), disable window's buttons. If time allows, I'll try your hack. 

Best regards,

Jozef

Tags
Editor
Asked by
Jozef
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Jozef
Top achievements
Rank 1
Share this question
or