gpt4 book ai didi

laravel - 在 Livewire 中强制重新加载整页

转载 作者:行者123 更新时间:2023-12-03 23:42:38 27 4
gpt4 key购买 nike

我用 火线 Alpine Laravel 8 .
我有一个带有 的页面数据表 (jQuery) 和一个 Bootstrap 模式。
该表填充了来自模型实例列表的一些数据。
当我单击表格中的按钮时,它会打开模态并允许编辑相应的记录。
这部分按预期工作。
然而,数据表库与 Livewire 一起使用要困难得多,所以我决定把整个 都放在一个范围内。数据表<div>wire:ignore属性。
因此,如果我想刷新 数据表做了修改后,我不能使用魔法$refresh因为数据表当前范围在 wire:ignore 内.
所以我想在编辑完成后重新加载整页,但我不知道如何做到这一点,return redirect()->back()不管用...
这是我的 save方法看起来像,当从模态编辑完成时调用它:

public function save()
{
MyModel::where('id', $this->edited_id)->update([...]);
$this->clearSelection();
return redirect()->back(); // This is not working
}
这是我的 table :
<div wire:ignore>
<table class="dt-table table">
<thead>
<tr>
<th>Actions</th>
<th>id</th>
<th>name</th>
<th>other</th>
</tr>
</thead>
<tbody>
@foreach ($models as $m)
<tr>
<td>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#mymodal">Edit</button>
</td>
<td>{{ $m->id }}</td>
<td>{{ $m->name }}</td>
<td>{{ $m->somedata }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>

最佳答案

Livewire 将原始 URL 存储在 Referer 中标题。您可以使用它来刷新页面:

return redirect(request()->header('Referer'));

关于laravel - 在 Livewire 中强制重新加载整页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64874410/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com