我需要从tinymce
删除带有div
的invoice_edit_modal
实例。我的代码是(我得到所有textareas
与类.product_comment
然后我尝试删除它们):
var productCommentsFields = $('#invoice_edit_modal .product_comment');
productCommentsFields.each(function(i, obj) {
var commentOldId = $(this).attr('id');
tinymce.remove('#invoice_edit_modal #'+commentOldId);
});
但它不起作用。我怎么解决这个问题?谢谢。
这不起作用,因为删除textarea dom元素不会影响javascript tinymce编辑器对象。
如果您为textareas提供了唯一的ID,则可以轻松删除这些编辑器,因为编辑器ID等于您的textarea ID。只需要调用每个textarea id:tinymce.get("your_textarea_id").remove();
对于其他情况:要详细说明如何解决您的问题,我需要了解更多关于您的dom结构。另外,你能告诉我tinymce.editors
在你的控制台中显示了什么吗?
在你能得到我的信息后,我会更新这个答案。
您需要在要删除的编辑器实例上调用remove()
方法。