Sonata 管理员删除确认弹出窗口 window
Sonata admin delete confirmation with pop-up window
我知道经典管理页面有删除和修改信息的确认,但那个确认是另一个页面。您能否将该确认页面设置为显示为弹出窗口 window 而不是另一个页面?
这可以通过 javascript 完成。您可以使用引导箱库。
http://bootboxjs.com/examples.html
Html:
<a href="#" data-href="id/delete">Delete</a>
在 javascript 中,为删除按钮创建侦听器:
$("a.confirm-delete").click(function(e) {
e.preventDefault();
var $link = $(this);
bootbox.confirm("Are you sure?", function(result) {
if (result == true) {
document.location.assign($link.attr('data-href'));
}
});
});
在你的控制器中:
/**
* @Route("/{id}/delete", requirements={"id" = "\d+"})
*/
public function deleteAction(Request $request, Product $p)
{
$this->em->remove($p);
$this->em->flush();
return new RedirectResponse($this->router->generate('route'));
}
我知道经典管理页面有删除和修改信息的确认,但那个确认是另一个页面。您能否将该确认页面设置为显示为弹出窗口 window 而不是另一个页面?
这可以通过 javascript 完成。您可以使用引导箱库。 http://bootboxjs.com/examples.html
Html:
<a href="#" data-href="id/delete">Delete</a>
在 javascript 中,为删除按钮创建侦听器:
$("a.confirm-delete").click(function(e) {
e.preventDefault();
var $link = $(this);
bootbox.confirm("Are you sure?", function(result) {
if (result == true) {
document.location.assign($link.attr('data-href'));
}
});
});
在你的控制器中:
/**
* @Route("/{id}/delete", requirements={"id" = "\d+"})
*/
public function deleteAction(Request $request, Product $p)
{
$this->em->remove($p);
$this->em->flush();
return new RedirectResponse($this->router->generate('route'));
}