ajaxsavetemplate.ui.js 615 B

123456789101112131415
  1. $(function()
  2. {
  3. /**
  4. * 把编辑器内容添加到表单中 post 到后台保存为模板。
  5. * Add the editor content to the form and post it to the background to save it as a template.
  6. */
  7. $(document).off('click', '#saveTemplate button[type=submit]').on('click', '#saveTemplate button[type=submit]', function()
  8. {
  9. const $form = $(this).closest('form');
  10. const editor = $form.find('input[name="editor"]').val();
  11. $('zen-editor[name="' + editor + '"]')[0].getHTML().then((content) => {
  12. $form.find('input[name="content"]').val(content);
  13. })
  14. });
  15. })