0

The dialogue box parts of this script work but the form doesn't submit

    $(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()
          }
      });

    }
  });
});
4

1 回答 1

0

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

$(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
          }
于 2013-08-29T23:52:51.710 回答