首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jquery提交不提交

jquery提交不提交
EN

Stack Overflow用户
提问于 2013-08-29 23:21:15
回答 1查看 75关注 0票数 0

此脚本的对话框部分工作,但表单不提交

代码语言:javascript
复制
    $(document).ready(function(){
  $("form#audit_delete_form").submit(function(e) {
    e.preventDefault();
    var $form = $(this);
    if ($form.find('select[name="audit_id_select"]').val() == "") {
        $.msgbox("Please select an audit", {
        type:"alert",
        buttons: [
        {type: "submit", value: "OK"}
        ]
      });
    }else{
        $.msgbox("Are you sure you want to permanently delete this audit?", {   
        type: "confirm",
         buttons : [
            {type: "submit", value: "Yes"},
            {type: "submit", value: "No"},
            {type: "cancel", value: "Cancel"}
          ]
      }, function(result){
          if(result == 'Yes'){
              $(this).submit()
          }
      });

    }
  });
});
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-08-29 23:52:51

无论如何,试着使用e.preventDefault();。然后,如果用户确认,则发出提交。

代码语言:javascript
复制
$(THE_SUBMIT_BUTTON_ID).click(function(e){
e.preventDefault();
if(...){...}
else{
        $.msgbox("Are you sure you want to permanently delete this audit?", {   
        type: "confirm",
         buttons : [
            {type: "submit", value: "Yes"},
            {type: "submit", value: "No"},
            {type: "cancel", value: "Cancel"}
          ]
      }, function(result){
          if(result == 'Yes'){
              $("form#audit_delete_form").submit() // We only submit when prompted
          }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18522481

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档