dongmu1996
2018-06-14 05:26
浏览 33
已采纳

从另一个叶片laravel显示模态

How can I display modal from another blade in the same directory laravel Ihave this button to display the view

@foreach
<a class="btn btn-primary" data-toggle="modal" data-target="#applicantModal{{$applicant->applicants_id}}">View</a>
@endforech

and then I put this into the controller

public function show()
{
      $applicants = Applicant::all();
      return view('applicant_list', compact('applicant'));
}

and then the modal

<div class="modal fade" id="applicantModal{{$applicant->$applicants_id}}" tabindex="-1" role="dialog" aria-labelledby="applicantModal">
        <div class="modal-dialog">
        <div class="modal-content">
        </div>
        </div>
</div>

图片转代码服务由CSDN问答提供 功能建议

如何从同一目录中的另一个刀片显示模式laravel 我有这个按钮来显示 查看

  @foreach 
&lt; a class =“btn btn-primary”data-toggle =“modal”data-target =“#applicantModal {{  $ applicant-&gt; applicants_id}}“&gt;查看&lt; / a&gt; 
 @ endforech 
   
 
 

然后我将其放入 控制器

  public function show()
 {
 $ applicants = Applicant :: all(); 
 return view('applicant_list',compact(' 申请人')); 
} 
   
 
 

然后 模态

 <  code>&lt; div class =“modal fade”id =“applicantModal {{$ applicant-&gt; $ applicants_id}}”tabindex =“ -  1”role =“dialog”aria-labelledby =“applicantModal”&gt; 
&lt;  ; div class =“modal-dialog”&gt; 
&lt; div class =“modal-content”&gt; 
&lt; / div&gt; 
&lt; / div&gt; 
&lt; / div&gt; 
   
 
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dprfe04886 2018-06-14 05:39
    已采纳

    Your modal file lets say abc.blade.php:

    <div class="modal fade" id="applicantModal{{$applicant->$applicants_id}}" 
    tabindex="-1" role="dialog" aria-labelledby="applicantModal">
        <div class="modal-dialog">
        <div class="modal-content">
        </div>
        </div>
    </div>
    

    Now you have to add Modal file inside foreach loop.

    @foreach
    @include('path/to/your/modal/file/abc.blade.php');
    <a class="btn btn-primary" data-toggle="modal" data- 
    target="#applicantModal{{$applicant->applicants_id}}">View</a>
    @endforech
    
    打赏 评论
  • dongyirong3564 2018-06-14 05:30

    You have a typo in your code use compact('applicants')

    public function show()
    {
          $applicants = Applicant::all();
          return view('applicant_list', compact('applicants'));
    }
    

    in your views try like this

    @foreach($applicants as $applicant)
    <a class="btn btn-primary" data-toggle="modal" data-target="#applicantModal{{$applicant->applicants_id}}">View</a>
    
    <div class="modal fade" id="applicantModal{{$applicant->$applicants_id}}" tabindex="-1" role="dialog" aria-labelledby="applicantModal">
            <div class="modal-dialog">
            <div class="modal-content">
            </div>
            </div>
    </div>
    
    @endforech
    

    Hope this helps.

    打赏 评论

相关推荐 更多相似问题