Cant write inside elRTE editor in dialog

Added by Uzivatel Mirek 10 months ago

Hi everyone,

I would like to put elRTE editor inside dialog with some form but when I show dialog everything looks perfect but there is problem that I am not able to write inside the editor:(

Here is my js code:

$(document).ready(function () {

            var opts = {
                cssClass: 'el-rte',
                lang: 'cs',
                allowSource: false,
                height: 450,
                width: 580,
                toolbar: 'complete',
                cssfiles: ['css/elrte-inner.css']
            }

            var rteInDialog = $('#editor');
            rteInDialog.elrte(opts);

            var dialog = $("#content").dialog({
                    width   : 750,
                    title   : "sddcsdcd",
                    modal   : true,
                    position: 'top',
                    autoOpen: false,
                });

            $("#justButton").click(function () {
                $("#content").dialog("open");
            });

            $("#obsahEditoru").click(function () {
                var content = $('#editor').elrte('val');
                alert(content);
            });
        });

And here is my HTML:

<div id="content">
        <table>
            <tr>
                <td>Předmět:</td>
                <td></td>
            </tr>
            <tr>
                <td>Zpráva:</td>
                <td><div id="editor">wedwedwedwedd</div></td>
            </tr>
            <tr>
                <td colspan="2"><input type="button" id="obsahEditoru" value="Zobrazit formulář" /></td>
            </tr>
        </table>
    </div>
    <input type="button" id="justButton" value="Zobrazit formulář" />

Thank you for your replies


Replies (9)

RE: Cant write inside elRTE editor in dialog - Added by Dmitry Levashov 10 months ago

You MUST create elRTE instance AFTER dialog opened - its iframe problem

RE: Cant write inside elRTE editor in dialog - Added by Uzivatel Mirek 10 months ago

thanks it works. Do you have any experience with elRTE and FancyBox? First time when I show the dialog everything is ok but when I close it and open it again I cant write:( And I create the editor when dialog is shown

$("#fancyLink").fancybox({
                'scrolling': 'no',
                // vlastnost autoDimensions musí být false a hodnoty
                // width a height fixní jinak při prvním spuštění FancyBox
                // se do něj celý formulář nevejde
                'autoDimensions': false,
                'width': 713,
                'height': 650,
                'titleShow': false,
                'easingIn': 'swing',
                'easingOut': 'swing',
                'transitionIn': 'elastic',
                'transitionOut': 'elastic',
                'onComplete': function () {
                    var rteInDialog = $('#editor');
                    rteInDialog.elrte(opts);
                },
            });

RE: Cant write inside elRTE editor in dialog - Added by Dmitry Levashov 10 months ago

Probably, you have to destroy elRTE before close and create after open

RE: Cant write inside elRTE editor in dialog - Added by Uzivatel Mirek 10 months ago

I have also tried this but this creates editor only first time and second time there is no editor.

This is the code I use:

$("#fancyLink").fancybox({
                'scrolling': 'no',
                'titleShow': false,
                'easingIn': 'swing',
                'easingOut': 'swing',
                'transitionIn': 'elastic',
                'transitionOut': 'elastic',
                'onComplete': function () {
                    $("#editor").elrte(opts);
                },
                'onClosed': function () {
                    $("#editor").elrte('destroy');
                },
            });

RE: Cant write inside elRTE editor in dialog - Added by Dmitry Levashov 10 months ago

Look in firebug for errors

RE: Cant write inside elRTE editor in dialog - Added by Uzivatel Mirek 10 months ago

firefox shows no errors. that is really strange:(

RE: Cant write inside elRTE editor in dialog - Added by Dmitry Levashov 10 months ago

when you click on icon - no errors and no elfinder dialog?
If so - give all you code

RE: Cant write inside elRTE editor in dialog - Added by Uzivatel Mirek 10 months ago

Now I know why it goes wrong when I use another then fade effect to display dialog. When I use fold, transfer and so on I am not able to write inside editor

RE: Cant write inside elRTE editor in dialog - Added by Dmitry Levashov 10 months ago

switch off animation - is a first step in debug not working scripts :)

(1-9/9)