Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.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控制器中sweetalert2中的链接_Php_Laravel_Sweetalert2 - Fatal编程技术网

Php 如何使整个确认按钮成为laravel控制器中sweetalert2中的链接

Php 如何使整个确认按钮成为laravel控制器中sweetalert2中的链接,php,laravel,sweetalert2,Php,Laravel,Sweetalert2,我在控制器中使用了一个sweetalert。“我的确认”按钮仅在您单击实际的“是”文本时起作用,因为这是链接所在的位置。如果我单击“确认”按钮上的其他任何位置,警报就会关闭。我想整个按钮都通过链接。多谢各位 public function show($id) { $user = User::find($id); Alert::warning('Deleting user -<br/>are you sure?') ->showCancelButton($btn

我在控制器中使用了一个sweetalert。“我的确认”按钮仅在您单击实际的“是”文本时起作用,因为这是链接所在的位置。如果我单击“确认”按钮上的其他任何位置,警报就会关闭。我想整个按钮都通过链接。多谢各位

public function show($id) {
  $user = User::find($id);

  Alert::warning('Deleting user -<br/>are you sure?')
    ->showCancelButton($btnText = 'Cancel', $btnColor = '#dc3545')
    ->showConfirmButton($btnText = '<a href="/admin/users/'. $id .'/delete">Yes</a>', $btnColor = '#38c177')
    ->autoClose(false);

  return redirect()->route('users.index');
}
公共功能显示($id){
$user=user::find($id);
警报::警告('删除用户-
您确定吗?') ->showCancelButton($btnText='Cancel',$btnColor='dc3545') ->showConfirmButton($btnText='',$btnColor='#38c177') ->自动关闭(假); return redirect()->route('users.index'); }
似乎库中没有API来添加任何操作,所以,您可以使用dirty hack:

为链接添加一些类,也将类添加到按钮:

Alert::warning('Deleting user -<br/>are you sure?')
    ->showCancelButton($btnText = 'Cancel', $btnColor = '#dc3545')
    ->showConfirmButton(
        $btnText = '<a class="add-padding" href="/admin/users/'. $id .'/delete">Yes</a>', // here is class for link
        $btnColor = '#38c177',
        ['className'  => 'no-padding'], // add class to button
    )->autoClose(false);

库似乎没有API来添加任何操作,因此,您可以使用dirty hack:

为链接添加一些类,也将类添加到按钮:

Alert::warning('Deleting user -<br/>are you sure?')
    ->showCancelButton($btnText = 'Cancel', $btnColor = '#dc3545')
    ->showConfirmButton(
        $btnText = '<a class="add-padding" href="/admin/users/'. $id .'/delete">Yes</a>', // here is class for link
        $btnColor = '#38c177',
        ['className'  => 'no-padding'], // add class to button
    )->autoClose(false);

将按钮更新为0填充和使用添加填充行更新链接都非常有效。非常感谢。将按钮更新为0填充和使用添加填充行更新链接都非常有效。非常感谢。