只要單擊Tinymce編輯器的「保存」按鈕,表單就會提交給服務器。我需要停止表單提交。我搜查了很多,但找不到任何解決方案。這裏是我的代碼,如何在單擊「保存」按鈕時停止提交jquery.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」,這會阻止表單提交。
從控件模板中刪除保存按鈕。這就是它的作用。 –
@AndrewBarber,有沒有辦法通過ajax提交表單? – user960567
這將是一個不同的問題,不是嗎? (我認爲其中一個已經被問及在這裏回答)。 –