1
我正在嘗試創建模態彈出窗口,並在模態內部包含AJAX調用。 該腳本包含AJAX。工作正常。使用Bootstrap和AJAX刪除確認模態
這裏是一個調用模式按鈕(我用嫩枝模板工作)
<button class="btn btn-danger" data-id="{{ product.id }}">Delete</button>
這是jQuery腳本:
$(document).ready(function() {
$('[data-id]').each(function() {
var $this = $(this),
id = $this.data('id');
$this.on('click', function(event) {
event.preventDefault();
$.post('{{ path('dashboard_ajax ') }}', {
'id': id
},
function(details) {
var $modal = $(details);
$('#confirm-delete').remove();
$('body').append($modal);
$modal.modal();
}
);
})
});
});
這是與模態
頁面<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Confirm Delete</h4>
</div>
<div class="modal-body">
<div class="alert alert-danger" role="alert">
<p>Do you really want to delete <b>{{ product.name }}?</b></p>
</div>
<img src="{{ asset('uploads/product_images/') }}{{ product.image }}" style="width: 240px;" class="img-responsive thumbnail" />
</div>
<div class="modal-footer">
<button type="button" id="misha" class="btn btn-default" data-dismiss="modal">Cancel</button>
<a class="btn btn-danger btn-ok">Delete</a>
</div>
</div>
</div>
現在,如果點擊刪除按鈕,我想刪除使用相關頁面選定的項目(例如mple:delete.php),你可以做
因爲這個問題,我只是想到http://t4t5.github.io/sweeta lert /它看起來也非常甜。謝謝,爲了記住我。 –