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
精彩评论