简体   繁体   中英

TinyMce: remove editor instance by id

I need to delete a tinymce instances from div with id invoice_edit_modal . My code is (I get all textareas with class .product_comment then I try to delete them):

var productCommentsFields = $('#invoice_edit_modal .product_comment');
productCommentsFields.each(function(i, obj) {
    var commentOldId = $(this).attr('id');
    tinymce.remove('#invoice_edit_modal #'+commentOldId);
});

But it doesn't work. How can I solve this problem? Thanks.

This won't work, because removing the textarea dom elements won't affect the javascript tinymce editor objects.

In case you gave your textareas unique ids you are able to remove those editors easily because the editor id equals your textarea id. Just call for each textarea id: tinymce.get("your_textarea_id").remove();

For other cases: To elaborate a bit on how to solve your problem i need to know a bit more about your dom structure. Plus, can you tell me what tinymce.editors shows in your console?

I will update this answer after you can get me that info.

您需要在要remove()任何编辑器实例上调用remove()方法。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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