您需要包括一個Ajax調用...實際提交數據......
是這樣的...
$(document).ready(function(){
$(".delete_action").click(function(event){
// incase the button is inside a form, this will prevent it from submitting
event.preventDefault();
// get your url
var url = '/admin/category/'+ event.target.id +'/delete';
// Create alert to confirm deletion
var conf = confirm("Are you sure you want to Delete this?");
if(conf){
// If they click yes
// submit via ajax
$.ajax({
url:url,
dataType:'json',
success:function(data){
//put anything you want to do here after success
// Probably remove the element from the page since you deleted it //So if the button is part of a parent div that needs to be removed.
}
});
}
});
});
你也可以使用$不用彷徨,而不是$就到縮短代碼更多...
$.get(url, function(data){
//remove element after success
});
但我意識到你試圖將URL傳遞給模態窗口,然後提交該模態窗口。所以你需要將ajax調用附加到模式窗口按鈕。不像上面那樣,只是打開一個警報窗口。它更簡單的方法,但看起來不那麼花哨。如果你真的想要一個模式。您需要將上述代碼附加到模態確認按鈕。但要點是一樣的。
嘗試過使用ajax嗎? –