如何在单击按钮时将tinymce内容重置为默认值

时间:2018-10-15 21:37:27

标签: tinymce reset

我试图将tinymce编辑器中的内容重置为单击按钮时的默认值。 这是我当前的tinymce初始化代码,并且在加载编辑器时也已初始化为设置默认内容。在按钮上单击我要运行setDefaultContent()函数,该函数用于tinymce.init

tinymce.init({             //常规选项

        selector: "textarea",
        editor_selector : "mceEditor",
        branding: false,
        **init_instance_callback: "setDefaultContent",**
        height : "300px",
        width : "1000",

        plugins: [
                "advlist autolink lists link image charmap print preview anchor",
                "searchreplace visualblocks code fullscreen",
                "insertdatetime media table contextmenu paste"
                    ],
        toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
        formats: {
        alignleft: {selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'myleft'},
        aligncenter: {selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'mycenter'},
        alignright: {selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'myright'},
        alignfull: {selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes: 'myfull'}
                    },
        content_style: '.myleft { text-align:left; } .mycenter { text-align:center; } .myright { text-align:right; } .myfull { text-align:justify; }', 
        forced_root_block: false
      }); 

1 个答案:

答案 0 :(得分:0)

如果您只想清除内容,请使用:

tinyMCE.activeEditor.setContent('');