javascript - TinyMCE reload editor - Stack Overflow

I have simple modal window with textarea:<div class="box-modal" id="product_modal&quo

I have simple modal window with 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_ment">{'TEXT_PRODUCT_COMMENT'|tr}:</span>
        <textarea id="product_ment" class="product_ment"></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.

My js:

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

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

So when I click in button in first time my tinymce works fine. 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). How can I remove old id instanse from editor for use them again?

Thanks.

I have simple modal window with 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_ment">{'TEXT_PRODUCT_COMMENT'|tr}:</span>
        <textarea id="product_ment" class="product_ment"></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.

My js:

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

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

So when I click in button in first time my tinymce works fine. 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). How can I remove old id instanse from editor for use them again?

Thanks.

Share Improve this question asked Sep 17, 2017 at 12:43 NgalexNgalex 411 gold badge1 silver badge2 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

You need to use the remove() API to detach TinyMCE from the DOM before you close your Modal window. You can then use init() again when the modal is recreated.

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742399789a4436679.html

相关推荐

  • javascript - TinyMCE reload editor - Stack Overflow

    I have simple modal window with textarea:<div class="box-modal" id="product_modal&quo

    3天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信