如何使用 SweetAlert2 重置 CKeditor4
How to reset CKeditor4 with SweetAlert2
我正在使用 SweetAlert2 作为表格。我希望当用户单击 Reset
按钮时出现 sweetalert。我已经完成所有工作弹出窗口出现,一些字段被重置但问题是 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);
}
}
}
});
}
});
这是工作 Fiddle,其中其他字段正在重置但不是 ckeditor,我该怎么做。 Click to see Fiddle
查看更新 at this updated jsfiddle。
添加以下内容即可(借自this answer:
CKEDITOR.instances.editor1
.setData( '', function() { this.updateElement(); } );
我正在使用 SweetAlert2 作为表格。我希望当用户单击 Reset
按钮时出现 sweetalert。我已经完成所有工作弹出窗口出现,一些字段被重置但问题是 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);
}
}
}
});
}
});
这是工作 Fiddle,其中其他字段正在重置但不是 ckeditor,我该怎么做。 Click to see Fiddle
查看更新 at this updated jsfiddle。
添加以下内容即可(借自this answer:
CKEDITOR.instances.editor1
.setData( '', function() { this.updateElement(); } );