如何将视图中的值传递给模态?

如何将视图中的值传递给模态?

问题描述:

我有这样的链接,我打开模式:如何将视图中的值传递给模态?

<li><a href="#deleteProperty{{$property->id}}" data-toggle="modal"><i class="fa fa-times"></i></a></li> 

,我已经在单独的页面模式modals.blade.php

<div class="modal fade modal_form" id="deleteProperty{{$property->id}}" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel5" aria-hidden="true"> 
       <div class="modal-dialog" role="document"> 
        <div class="modal-content"> 
         <div class="modal-header"> 
          <button type="button" class="close" data-dismiss="modal" aria-label="Close"> 
           <span aria-hidden="true">&times;</span> 
          </button> 
          <h4 class="modal-title" id="exampleModalLabel5">Are you sure you want to delete this property?</h4> 
         </div> 
         <div class="modal-body"> 
         <form method="POST" action="{{ route('user.property.delete',[$user->id,$property->id])}}"> 
          <div class="form-group"> 
          <div class="left-btn"> 
           <button type="button" class="btn btn-primary" data-dismiss="modal">No</button> 
          </div> 
          <div class="right-btn"> 
            <button type="submit" class="btn btn-primary">Yes</button> 
          </div> 
          </div> 
         </form> 
         </div> 
        </div> 
       </div> 
      </div> 

如何传递这个参数($性财产> ID)模式,所以当用户点击特定属性时,删除该属性?

+0

引导模式! – None

+0

您已将值传递给* bootstrap模态*。这只是使用jQuery(?)来访问'.modal' div的'id'属性。 – apokryfos

+0

当我通过这个值,我得到一个错误未定义变量属性 – None

您需要传递要在包含的视图中使用的变量。

例子:

@include('standardUser.includes.modals', [ "property" => $property ]) 
+0

我不能这样做,因为在布局我没有财产 – None

+0

你需要重新考虑你的策略。你需要在解决所有属性后包含视图,或者你应该使用'View :: share('property','$ property)',但这对你的情况来说只是不好的做法。 – apokryfos