2017-09-15 22:41:38 2235次浏览 0条回答 0 悬赏 10 金钱
jQuery(document).ready(function () {
jQuery('#postform-comment').redactor({"imageManagerJson":"/frontend/web/redactor/upload/image-json","lang":"zh_cn","plugins":["clips","fontcolor","imagemanager"],"imageUpload":"/frontend/web/redactor/upload/image","fileUpload":"/frontend/web/redactor/upload/file","imageUploadErrorCallback":function(json){alert(json.error);},"fileUploadErrorCallback":function(json){alert(json.error);}});
jQuery('#PostForm').yiiActiveForm([{"id":"postform-comment","name":"comment","container":".field-postform-comment","input":"#postform-comment","error":".help-block.help-block-error","enableAjaxValidation":true,"validate":function (attribute, value, messages, deferred, $form) {yii.validation.string(value, messages, {"message":"评论区必须是一条字符串。","max":100,"tooLong":"评论区只能包含至多100个字符。","skipOnEmpty":1});}}], []);
$('form#PostForm').on('beforeSubmit', function(e) {
   var $form = $(this);
   alert(1);   (3// do whatever here, see the parameter $form? is a jQuery Element to your form

}).on('submit', function(e){
    alert(2);  //(1) (4)
    e.preventDefault();
    alert(3);  //(2)   (5)
});
});

疑问点:我是按着别个的教程来的,但是当我提交表单的时候,alert弹出的内容依次为 2 3 1 2 3
百思不得其解 为嘛这样写 当我第一次提交表单的时候 弹出了5个值(像点击一次却提交了2次表单一样) ,不刷新继续点击,第二次弹出的顺序为1,2,3 (这才是正常的嘛) 求解:这是为什么,还有上面不是(2)处那明明已经阻止了表单提交了么 为什么
还是提交信息到服务器了啊?

补充于 2017-09-15 22:42

S6N`AI6IO0{J1{NM09~K970.png

补充于 2017-09-15 22:47

http://www.yiichina.com/tutorial/432 这是我看的那个教程的路径

补充于 2017-09-16 11:31

如何接收yii2的ajax隐形提交验证之后的返回值啊?

    没有找到数据。
您需要登录后才可以回答。登录 | 立即注册
胡爽yii
助理

胡爽yii

注册时间:2017-07-18
最后登录:2018-02-02
在线时长:8小时6分
  • 粉丝0
  • 金钱65
  • 威望0
  • 积分145

热门问题