如何停止Jquery.TinyMCE从我单击保存按钮时提交

时间:2012-05-10 15:38:10

标签: javascript jquery tinymce

每当我点击Tinymce Editor的Save按钮时,表单都会提交给服务器。我需要停止表单提交。我搜索了很多但找不到任何解决方案。这是我的代码,

$('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”,这将阻止表单提交。

1 个答案:

答案 0 :(得分:2)

我找到了答案。挖掘源我发现我可以添加,

onsubmit = "return false" 
表单标签上的

将阻止表单提交。

相关问题