如何在 Laravel 中渲染不包含布局的视图
有一些我们想要在页面中通过Ajax弹出模态框,但这些模态框视图继承自一个布局,这样就会在模态框中会显示包含布局的完整视图,而我们实际上想要的效果是不包含布局的视图。使用renderSections()是针对该问题的解决办法,下面是实现代码:
// In my ViewingTimesController
public function getTimesForSale(Request $request,Sale $sale)
{
// Do some logic
if($request->ajax()) {
return view('viewing_times.view_times',compact('viewing_times','catalogue_sections'))
->renderSections()['content'];
}
// return the standard full view
}
No Comments