代码之家  ›  专栏  ›  技术社区  ›  GermanCoder

如何使用SweetAlert2重置CKeditor4

  •  1
  • GermanCoder  · 技术社区  · 8 年前

    我正在使用 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);
                        }
                    }
                }
            });
        }
    });
    

    这是一个其他字段正在重置而不是ckeditor的工作小提琴,我如何才能做到这一点。 Click to see Fiddle

    1 回复  |  直到 8 年前
        1
  •  1
  •   Blue    8 年前

    请参阅更新 at this updated jsfiddle .

    添加以下内容即可(借用自 this answer :

    CKEDITOR.instances.editor1
       .setData( '', function() { this.updateElement(); } );
    
    推荐文章