I am using SweetAlert2 for a form. I want when a user click on Reset
button that sweetalert appears. I have done all work popup is appearing and some of fields are reset but the problem is with CKeditor4 it's not reseting. Usually I am using (given below) script for reseting 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);
}
}
}
});
}
});
Here is the working Fiddle in which other fields are reseting but not ckeditor, how can I do that. Click to see Fiddle
See update at this updated jsfiddle.
Adding the following should do it (Borrowed from this answer:
CKEDITOR.instances.editor1
.setData( '', function() { this.updateElement(); } );