Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 确认和取消按钮Laravel Sweet Alert_Php_Laravel_Sweetalert - Fatal编程技术网

Php 确认和取消按钮Laravel Sweet Alert

Php 确认和取消按钮Laravel Sweet Alert,php,laravel,sweetalert,Php,Laravel,Sweetalert,早上好: 我正在尝试在Laravel中使用插件Sweet Alert。 我的问题是,我不知道如何在控制器中使用“取消”按钮和“确认”按钮发出警报。 阅读文档时,我只发现这句话: Alert::warning('Are you sure?', 'message')->persistent('Close'); 此外,我正在尝试: echo '<script>swal({ title: "Are you sure?", text: "name is available, conti

早上好:

我正在尝试在Laravel中使用插件Sweet Alert。 我的问题是,我不知道如何在控制器中使用“取消”按钮和“确认”按钮发出警报。 阅读文档时,我只发现这句话:

Alert::warning('Are you sure?', 'message')->persistent('Close');
此外,我正在尝试:

echo '<script>swal({ title: "Are you sure?", text: "name is available, continue save?", type: "warning", showCancelButton: true, confirmButtonColor:"#DD6B55",  confirmButtonText: "Yes, delete it!",   closeOnConfirm: false }, function(){});</script>';
echo'swal({title:“您确定吗?”,文本:“名称可用,继续保存?”,键入:“警告”,showCancelButton:true,confirButtonColor:“#DD6B55”,confirButtonCext:“是,删除它!”,closeOnConfirm:false},function(){};”;
但它不起作用

如何在显示取消按钮和确认按钮的控制器中使用Sweet Alert

谢谢

如果您正在使用回购协议,那么我坚持要求您仔细阅读文档,因为它给出了如何使用您基本上正在寻找的适当片段生成警报

回购协议本身的片段

控制器

您的控制器应该如下所示

public function yourfunction()
{
    Alert::warning('Are you sure?', 'message')->persistent('Close');

    return to whatever view    
   //return redirect::home();
}
查看

在从store方法重定向的视图中,应该执行repo中给出的操作

@if (Session::has('sweet_alert.alert'))
    <script>
        swal({
            text: "{!! Session::get('sweet_alert.text') !!}",
            title: "{!! Session::get('sweet_alert.title') !!}",
            timer: {!! Session::get('sweet_alert.timer') !!},
            type: "{!! Session::get('sweet_alert.type') !!}",
            showConfirmButton: "{!! Session::get('sweet_alert.showConfirmButton') !!}",
            confirmButtonText: "{!! Session::get('sweet_alert.confirmButtonText') !!}",
            confirmButtonColor: "#AEDEF4"

            // more options
        });
    </script>
@endif
@if(会话::has('sweet\u alert.alert'))
游泳({
text:“{!!Session::get('sweet\u alert.text')!!}”,
标题:“{!!会话::获取('sweet\u alert.title')!!}”,
计时器:{!!会话::get('sweet\u alert.timer')!!},
类型:“{!!Session::get('sweet\u alert.type')!!}”,
showConfirmButton:“{!!Session::get('sweet_alert.showConfirmButton')!!}”,
confirmButtonText:“{!!会话::获取('sweet_alert.confirmButtonText')!!}”,
confirmButtonColor:“AEDEF4”
//更多选择
});
@恩迪夫

PS::我还没有用过甜警报,但这种回购很酷!它有所有你想知道的关于甜警报

嗨,你在用这个回购协议吗?看起来他在用那个。我个人认为图书馆创造的工作比必要的多。像这样简单的事情;swal({title:'you sure?',text:'将添加产品',键入:'info',showCancelButton:true,confirButtonText:'Yes,import!',cancelButtonText:'No,Cancel'})应该可以工作。只需包含脚本就可以了。在HTML中包含sweetalert2脚本之后,您是否在Laravel之外尝试过这个方法?可能脚本没有包括在内。看来他正在尝试从控制器本身调用,因为他正在使用echo。谢谢你的回答。是的,我使用的是Laravel 5.4中Github的Sweet Alert,我无法显示带有de代码的confir按钮来提供文档。只能显示关闭按钮:->持久(“关闭”);我读到一种在控制器中使用“echo”的方法。但是,我正在测试,没有工作。嗨。我需要在控制器中显示确认和取消按钮。当有条件成功时,在保存之前。->持续(“关闭”);这对我来说是不够的。但是你可以用showConfirmButton。你试过了吗?很抱歉耽搁了。你的意思是我可以使用->持久('showConfirmButton')??好的,谢谢!然而,我在文档中没有看到它。无论如何,我会试试。我已经从docs bro添加了此代码。如果您发现任何困难,我们会尝试解决,如果您得到了想要的,请接受答案以结束此问题。谢谢:)