4

Kendo Editor + show (& ldquo; slide & rdquo;) can not be edited in Firef...

 2 years ago
source link: https://www.codesd.com/item/kendo-editor-show-slide-can-not-be-edited-in-firefox.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Kendo Editor + show (& ldquo; slide & rdquo;) can not be edited in Firefox

advertisements

Please refer to JSFiddle for a working demonstration of this problem.

In Firefox (latest version, 24), if I use jQuery UI's .show("slide", { direction: "right" }) to display a kendoEditor, the editor does not contain the value I set it with, and it is not editable. If I use the plain old .show() from jQuery, then everything works fine. It also works fine in Chrome 30 and IE 10. Why does .show("slide") break the editor in Firefox, and are there any workarounds for this problem?

Html for this example:

<button id="btn1" type="button">Button 1</button>
<button id="btn2" type="button">Button 2</button>
<div id="div">
    <textarea data-role="editor" data-bind="value: TheValue"></textarea>
    <button id="hide" type="button">Hide</button>
</div>

This is the JS code that does not work:

$(document).ready(function () {
    var model;
    function bindDiv(value) {
        model = kendo.observable({ TheValue: value });
        kendo.bind($('#div'), model);
        $('#div').show("slide", { direction: "right" });
        //$('#div').show();
    }
    $('#div').hide();
    $('#btn1').click(function () { bindDiv('hello'); });
    $('#btn2').click(function () { bindDiv('goodbye'); });
    $('#hide').click(function () {
        console.log(model.get('TheValue'));
        $('#div').hide("slide", { direction: "right" });
        //$('#div').hide();
    });
});

Clicking btn1 should result in the editor being display with the text "hello", and then clicking "Hide" should display the edited text in the console. If you replace those two "slide" lines with the plain commented-out versions, then it works fine (but doesn't look as cool).

Does anyone know why this doesn't work, or what I can do about it?

Update:

Before the animation plays, everything is OK - the body of the editor's iframe has the correct content and is marked with the contenteditable attribute. After the animation completes, the body of the iframe is wiped clean - no content, no attributes. I'm still trying to figure out why and what to do about it.


If you upgrade your KenoUI version to the latest Q2 2013 (version 2013.2.716) then the Kendo Editor has a new method called: refresh which

refresh
Reinitializes the editing area iframe. Should be used after moving the editor in the DOM.

So it does exactly what you need, because the animation moves the editor iframe you need to call refresh when it finishes:

$('#div').show("slide", { direction: "right" }, function () {
    var editor = $("#editor").data("kendoEditor");
    editor.refresh();
});

To make this work you also need to change your view and give an id to you textarea:

<div id="div">
    <textarea id="editor" data-role="editor" data-bind="value: TheValue">
    </textarea>
</div>

Demo JSFiddle.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK