1

我有带有复选框的用户列表,因此该功能至少是一个复选框必须选择其他使用jquery完成的验证来删除选定的用户,一旦验证完成,应该出现确认消息框询问确认是或否删除. 所以下面是我没有确认消息框的代码

  function delete(element,servlet,formName){
    var form = element.form;   
    $(document).ready(function() {  
    $(form ).validationEngine({  
      submitHandler: function(form) {    
       $(form).ajaxSubmit();    
   }   
  })   
 });   
}  

所以我应该在哪里插入确认消息框,提前谢谢

4

5 回答 5

2
$("#deletebutton").bind('click', function(){
    if(confirm('delete?')){
        $('input:checked').each(function(){
            deleteFunction(this.id);
        });
    }
});

并且标记应该是

<ul>
  <li><input type="checkbox" id="name_1" name="name_1" />name 1</li>
  <li><input type="checkbox" id="name_2" name="name_2" />name 2</li>
  <li><input type="checkbox" id="name_3" name="name_3" />name 3</li>
  <li><input type="checkbox" id="name_4" name="name_4" />name 4</li>
  <li><input type="checkbox" id="name_5" name="name_5" />name 5</li>
</ul>
<button id="deletebutton">del</button>
于 2010-09-29T15:15:52.757 回答
2
$(form).ajaxSubmit({
    success: function() {
        alert('user successfully deleted');
    }
});
于 2010-09-29T15:08:03.157 回答
0

提交前确认

submitHandler: function(form) {
    if (confirm("really delete that dude?")) {
        $(form).ajaxSubmit();
    }
}
于 2010-09-29T15:14:33.733 回答
0
function delete(element,servlet,formName){
    var form = element.form;   
    $(document).ready(function() {  
    $(form ).validationEngine({  
      submitHandler: function(form) {    
       $(form).ajaxSubmit({
          dataType:  'json', 
          success: function(data) {
              if (data.okDelete) // json response
                 alert('ok deleted');
              else
                 alert('error deleted');
          }
       });    
    }   
  })   
 });   
}  
于 2010-09-29T15:16:33.727 回答
0

I think you need jQuery dialog to show a confirmation dialog with some buttons. First, you define a div for the dialog. Then, the buttons which you want to show. With the function within it, the action if the button is clicked. Last, create a dialog. You can place the code as a replacement of line : $(form).ajaxSubmit();
So, you create a dialog before you submit the form. Hope this help.

var dialog_="<div title='Confirmation'><span class='ui-icon ui-icon-alert' style='float:left; margin:0 7px 20px 0;'></span>";

buttons_confirm['Yes']=function() {
   $(form).ajaxSubmit();
   $(this).dialog('close');
};
buttons_confirm['Cancel']=function() {
   $(this).dialog('close');
};
$(dialog_).dialog({
    bgiframe: true,
    resizable: false,
    modal: true,
    buttons: buttons_confirm                
});
于 2010-09-29T15:27:17.523 回答