javascript - 单击“保存”按钮时如何阻止 Jquery.TinyMCE 提交

标签 javascript jquery tinymce

每当我单击 Tinymce 编辑器的“保存”按钮时,表单就会提交到服务器。我需要停止表单提交。我进行了很多搜索,但找不到任何解决方案。这是我的代码,

$('textarea.tinymce').tinymce({
    paste_retain_style_properties : "margin, padding, width, height, font-size, font-weight, font-family, color, text-align, ul, ol, li, text-decoration, border, background, float, display",
    script_url : path_global+'/js/TinyMCE/tiny_mce.js',
    valid_children : "+body[style]",
    theme : "advanced",
    plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
    theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
    theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
    theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
    theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    theme_advanced_statusbar_location : "bottom",
    theme_advanced_resizing : true,
     setup : function(ed) {         
      ed.onSaveContent.add(function(ed, l) {
       });
  }
});

更新:我找到了答案。深入研究源代码,我发现我可以在表单标记上添加 onsubmit =“return false”,这将阻止表单提交。

最佳答案

我已经找到答案了。深入研究源代码,我发现我可以添加,

onsubmit = "return false" 

在表单标记上,这将阻止表单提交。

关于javascript - 单击“保存”按钮时如何阻止 Jquery.TinyMCE 提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10537513/

相关文章:

javascript - 计算用户使用 jquery 或 javascript 将元素悬停了多少秒?

javascript - HTML5 混合应用程序的 CORS

jquery - 如何在放置后将可拖动对象保持在其原始位置

tinymce - 用PHP7在moxiemanager中出错

jquery - 为什么 Tinymce 第二次加载失败?

javascript - 在Javascript中根据arraykey将字符串插入数组

javascript - 使用 jquery 平滑滚动

javascript - 为什么我不能切换类(class)?

javascript - Angular - 添加选项以使用 Jquery 进行选择

html - 如何使用 TinyMCE 的默认视频嵌入代码创建缩略图?