Confirm和取消按钮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>';

But it not working.



hi are you using this repo? 金字塔
它看起来像是用那个。我个人认为图书馆比必要的工作创造了更多的工作。这么简单的东西; Swal({Title:'你确定吗?',文字:'将添加该产品。',键入:'info',showcancelbutton:true,confirectnbuttontext:'是,导入它!',cancelButtontext:'否,取消' }) 应该管用。只包括和那就是它。Comity
it appears he is trying to call from controller itself as he is using echo for 金字塔
Thanks for your answers. Yes I am using Sweet-Alert from Github in Laravel 5.4 I can´t show a confir button with de code that give me the documentation. Only can show a Close Button: ->persistent('Close'); I read a way doing it with "echo" in the Controller. However, I am testing and not working.Miguel Herereros Cejas

回答 1

  1. 赞同 2

    如果您正在使用this repo then I insist you to read the docs thoroughly as it is given how generate alerts with proper snippets You are basically looking for this

    Snippet from the repo itself


    Your controller should look like this

    public function yourfunction()
        Alert::warning('Are you sure?', 'message')->persistent('Close');
        return to whatever view    
       //return redirect::home();


    @if (Session::has('sweet_alert.alert'))
                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

    PS ::我还没有使用甜蜜的警报,但这个回购很酷!它拥有所有你想了解甜蜜警报的一切!

    mr 金字塔
    我需要在控制器中显示一个按钮并取消。当条件成功和之前保存。 - >持久('关闭');这对我来说还不够。Miguel Herereros Cejas
    but you can use showConfirmButton for that have you tried that??mr 金字塔
    延迟纪念品。你的意思是我可以使用 - >持久('showconfirmbutton')??Miguel Herereros Cejas
    OK,谢谢!但是,我没有在文档中看到它。无论如何,我会尝试一下。Miguel Herereros Cejas
    我从Docs兄弟添加了这个代码,试一试如果您发现任何困难,我们将尝试修复,同时如果您得到了您想要的那样,请接受关闭此问题的答案谢谢:)mr 金字塔