开发者

JQuery dialog destroy

How can I implement in jQuery to call in the dialog "Ok" function the destroy method?

$('.dialog').dialog({
  autoOpen: false,
  width: 600,
  buttons: {
    "Ok": function() { 
      $(this).dialog("close");
    }, 
    "Cancel": function() { 
      $(this).dialog("close"); 
    } 
  }
});

$('.dialog_link').click(function(){
  $('.dialog').dialog('open');
  return false;
});
开发者_Go百科

Thanks for your help!


You will have to use an AJAX request.

Read the documentation here: http://api.jquery.com/jQuery.ajax/


Here the solution

HTML:

<a href="users/***Item id***"

JQuery:

$('.dialog_link').click(function(){
  url = this;

  $('.dialog').dialog('open');
  return false;
});

$('.dialog').dialog({
  autoOpen: false,
  width: 600,
  buttons: {
    "Ok": function() {
      $.ajax({
        url: url,
        type: 'post',
        data: { '_method': 'delete' },
        success: function(html){
          $("body").html(html)
        }
    })
    $(this).dialog("close"); 
    }, 
    "Cancel": function() { 
    $(this).dialog("close"); 
    } 
  }
});

Kind regards shub

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜