2016-11-08 86 views
3

我有這樣的鏈接,我打開模式:如何將視圖中的值傳遞給模態?

<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

回答

1

您需要傳遞要在包含的視圖中使用的變量。

例子:

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

我不能這樣做,因爲在佈局我沒有財產 – None

+0

你需要重新考慮你的策略。你需要在解決所有屬性後包含視圖,或者你應該使用'View :: share('property','$ property)',但這對你的情況來說只是不好的做法。 – apokryfos

相關問題