简体   繁体   English

TinyMCE重新加载编辑器

[英]TinyMCE reload editor

I have simple modal window with textarea: 我有带textarea的简单模态窗口:

<div class="box-modal" id="product_modal">
    <div class="box-modal_close arcticmodal-close"><img id="closePopupImage" src="/images/icons/popup_icon_close.png"></div>
    <div id="product_fields">
        <span class="product_label">{'TEXT_PRODUCT_NAME'|tr}:</span>
        <input type="text" class="product_name">
        <span>{'TEXT_PRODUCT_PRICE'|tr}:</span>
        <input type="text" class="product_price">
        <span>{'TEXT_PRODUCT_AMOUNT'|tr}:</span>
        <input type="text" class="product_amount">
        <br>
        <span class="product_label pr_comment">{'TEXT_PRODUCT_COMMENT'|tr}:</span>
        <textarea id="product_comment" class="product_comment"></textarea>
        <img class="add_one_more" src="/images/icons/add_button.png" title="{'TEXT_ADD_ONE_MORE'|tr}">
    </div>
</div>

I have table with button with class .add_products_btn. 我有带有类.add_products_btn的按钮的表。

My js: 我的js:

 function makeTinyMceEditor() {
            tinymce.init({
                selector: "#product_comment",
                plugins: "link"
            });
    }

$(".add_products_btn").click(function () {
        $("#product_modal").arcticmodal();
        makeTinyMceEditor();
    });

So when I click in button in first time my tinymce works fine. 因此,当我第一次单击按钮时,我的tinymce可以正常工作。 But when I click on the second button my tinymce doesn't work (think because textarea's ids are the same every time when I click on the button). 但是,当我单击第二个按钮时,我的tinymce不起作用(请考虑一下,因为每次单击该按钮时textarea的ID都是相同的)。 How can I remove old id instanse from editor for use them again? 如何从编辑器中删除旧ID实例以再次使用?

Thanks. 谢谢。

You need to use the remove() API to detach TinyMCE from the DOM before you close your Modal window. 关闭“模态”窗口之前,需要使用remove() API将TinyMCE与DOM分离。 You can then use init() again when the modal is recreated. 然后,可以在重新创建模态时再次使用init()

https://www.tinymce.com/docs/api/tinymce/root_tinymce/#remove https://www.tinymce.com/docs/api/tinymce/root_tinymce/#remove

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM