Chr*_*DLH 3 laravel eloquent bootstrap-modal bootstrap-4 laravel-livewire
我正在使用 laravel livewire 删除两个表中的记录,问题是模式,记录正在被删除,但模式仍然显示。
\n奇怪的是,当我注释其中一行代码来删除数据时,它起作用了!
\n我正在使用 Bootstrap 4.1
\n这是我的功能:
\n public function delete($id)\n {\n DB::beginTransaction();\n try \n { \n // If I comment on any of the following two lines (it doesn't matter what line it is), it works! \n\n DetalleRamComputadora::where('fk_computadora', '=', $id)->delete();\n Computadora::where('id', '=', $id)->delete();\n\n DB::commit();\n $this->emit('confirm'); // Close modal "confirm"\n session()->flash('success', 'Registro eliminado con \xc3\xa9xito');\n\n } catch (\\Throwable $th) {\n DB::rollBack();\n $this->emit('confirm'); // Close modal "confirm"\n session()->flash('error', 'Ocurri\xc3\xb3 un error y no se almacen\xc3\xb3 el registro');\n }\n }\nRun Code Online (Sandbox Code Playgroud)\n这是从 Livewire 关闭模式的脚本:
\nwindow.livewire.on('confirm', () => {\n $('#delete_confirm').modal('hide');\n}); \nRun Code Online (Sandbox Code Playgroud)\n请帮帮我!!
\n我能够解决这个问题。只有我在模态的 div 中添加了这段代码
**wire:ignore.self**
<div wire:ignore.self class="modal fade" id="delete_confirm" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
...
</div>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13194 次 |
| 最近记录: |