我正在使用SweetAlert2表单。我希望当用户点击sweetalert出现的Reset
按钮时。我已经完成了弹出窗口的所有工作并重置了一些字段,但问题在于 CKeditor4 它没有重置。通常我使用(如下所示)脚本重置CKeditor:
的 JS
$(function() {
if (typeof CKEDITOR != 'undefined') {
$('form').on('reset', function(e) {
if ($(CKEDITOR.instances).length) {
for (var key in CKEDITOR.instances) {
var instance = CKEDITOR.instances[key];
if ($(instance.element.$).closest('form').attr('name') == $(e.target).attr('name')) {
instance.setData(instance.element.$.defaultValue);
}
}
}
});
}
});
这是工作小提琴,其他字段正在重置但不是ckeditor,我该怎么做。 Click to see Fiddle
答案 0 :(得分:1)
请参阅更新at this updated jsfiddle。
添加以下内容应该这样做(借用this answer:
CKEDITOR.instances.editor1
.setData( '', function() { this.updateElement(); } );