使用Javascript/Bootstrap删除的Laravel路由复选框
我在Laravel(PHP框架)中编写了一个公式,这个公式得到一些数据,并通过一个路由发送到我的控制器。我的控制器具有从数据库中删除数据的功能。现在我想要一个javascript/引导复选框,并发现:使用Javascript/Bootstrap删除的Laravel路由复选框,javascript,php,twitter-bootstrap,laravel,Javascript,Php,Twitter Bootstrap,Laravel,我在Laravel(PHP框架)中编写了一个公式,这个公式得到一些数据,并通过一个路由发送到我的控制器。我的控制器具有从数据库中删除数据的功能。现在我想要一个javascript/引导复选框,并发现: <script> bootbox.confirm("Are you sure?", function(result) { Example.show("Confirm result: "+result);
<script>
bootbox.confirm("Are you sure?", function(result) {
Example.show("Confirm result: "+result);
});
</script>
当前代码:
{!! Former::horizontal_open()->method('DELETE')->action(action("Test\\TestController@destroy", $thread->id))->id('conf') !!}
{!! Former::large_danger_submit('Delete') !!}
<script>
$('.conf').submit(function(event) {
event.preventDefault();
var subm = confirm("Are you sure?");
if(subm){
$('.conf p').text('Pressed Ok');
this.submit();
}else{
$('.conf p').text('Pressed Cancel');
return false;
}
});
</script>
{!! Former::close() !!}
{!!Former::horizontal_open()->method('DELETE')->action(action(“Test”)\\TestController@destroy“,$thread->id”)->id('conf')
{!!前者::大危险提交('Delete')
$('.conf').submit(函数(事件){
event.preventDefault();
var subm=确认(“您确定吗?”);
if(subm){
$('.conf p').text('Pressed Ok');
这个。提交();
}否则{
$('.conf p').text('Pressed Cancel');
返回false;
}
});
{!!前::关闭()!!}
像这样获取j.query、javascript和引导:
整个master.blade.php:
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
</head>
<body>
@include("elements.navbar")
<div class="container">
<hr />
@yield('content')
<hr />
</div>
@yield('custom-script')
<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
</body>
</html>
@包括(“elements.navbar”)
@产量(‘含量’)
@yield('custom-script')
带有表单的HTML和JS确认代码当然可以获取master.blade.php的数据。因此支持查询和JS/Bootstrap
**Jquery required.**
另一种没有引导盒的方式
<html>
<head>
//head
</head>
<body>
@include("elements.navbar")
<div class="container">
<hr />
@yield('content')
<hr />
</div>
<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
@yield('custom-script')
</body>
</html>
//头
@包括(“elements.navbar”)
@产量(‘含量’)
@yield('custom-script')
您的表单视图
{!! Former::horizontal_open()->method('DELETE')->action(action("Test\\TestController@destroy", $thread->id))->id('conf') !!}
{!! Former::large_danger_submit('Delete') !!}
{!! Former::close() !!}
@section('custom-script')
<script>
//DOM Ready
$(function(){
$('#conf').submit(function(event) {//form ID (not Class as you have ->id('conf'))
event.preventDefault();
var subm = confirm("Are you sure?");
if(subm){
console.log('Press Ok')
this.submit();
}else{
console.log('Press Cancel')
return false;
}
});
});
</script>
@stop
{!!Former::horizontal_open()->method('DELETE')->action(action(“Test”)\\TestController@destroy“,$thread->id”)->id('conf')
{!!前者::大危险提交('Delete')
{!!前::关闭()!!}
@节(“自定义脚本”)
//DOM就绪
$(函数(){
$('#conf').submit(函数(事件){//form ID(不是像您所拥有的类->ID('conf'))
event.preventDefault();
var subm=确认(“您确定吗?”);
if(subm){
console.log('按Ok')
这个。提交();
}否则{
console.log('按取消')
返回false;
}
});
});
@停止
或者是另一种确认方式……嗯,我需要选择不带bootbox的方式,因为我没有bootbox的软件包。。我安装了Jquery,但启动盒不在其中。。你能告诉我怎样把第二种方法和我的公式联系起来吗?如果它是真的,请转到我的控制器中的destroy方法,否则什么也不做?我不知道,好吧,它现在的形式,我没有得到任何错误,线程只是将被删除。Jquery在我的网络控制台中加载Javascript之前——我只需要一个普通的确认,如果它为真,我将被重定向到另一个站点我的意思是,如果确认为真(按下OK),那么我将被重定向到另一个站点。否则什么也不会发生。这是我唯一想得到的东西,但它仍然做同样的事情,只是删除线程,仅此而已,没有确认:/it在Fiddle中工作。。这就是为什么我认为我的状态有问题。我会用我的表格和其他东西更新我的问题
{!! Former::horizontal_open()->method('DELETE')->action(action("Test\\TestController@destroy", $thread->id))->id('conf') !!}
{!! Former::large_danger_submit('Delete') !!}
{!! Former::close() !!}
@section('custom-script')
<script>
//DOM Ready
$(function(){
$('#conf').submit(function(event) {//form ID (not Class as you have ->id('conf'))
event.preventDefault();
var subm = confirm("Are you sure?");
if(subm){
console.log('Press Ok')
this.submit();
}else{
console.log('Press Cancel')
return false;
}
});
});
</script>
@stop