2016-08-12 83 views
1

我是laravel framework.please的新手,你能幫我找到這個好的解決方案嗎?可能這是一件小事情,但我並沒有對它進行不幸的處理。Laravel 5.1 - @include標記不起作用

<!DOCTYPE html> 
    <html lang="en"> 
    <head> 
     <title>Site</title> 
     <meta charset="utf-8"> 
     <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js">  </script> 
     <script  src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js">  </script> 
    </head> 
     <body> 

<div class="container"> 

    <div class="panel panel-default"> 
    <div class="panel-heading"> 
    <button type="button" class="btn btn-info" id="add">New Site</button> 
</div> 

<div class="panel-body"> 
    @include('newSite') 
    <table class="table table-hover"> 
    <caption>Site Info</caption> 
    <thead> 
     <th>Site ID</th> 
     <th>Site Name</th> 
     <th>Date</th> 
     <th>Description</th> 
    </thead> 

    <tbody> 
     @foreach($sites as $key => $site) 
     <tr id="site{{$site->site_id}}"> 
     <td>{{$site->site_id}}</td> 
     <td>{{$site->site_name}}</td> 
     <td>{{$site->site_description}}</td> 
     <td> 
      <button class="btn btn-success btn-edit">Edit</button> 
      <button value="btn btn-danger btn-delete">Delete</button> 
     </td> 
     </tr> 
      @endforeach 
     </tbody> 
     </table> 
    </div> 
    </div> 


    <script type="text/javascript"> 
    $("#add").on('click',function(){ 
    $('#site').modal('show'); 
    }) 
</script> 


</div> 

</body> 
</html> 

這是我的看法site.blade.php需要file.i包括newSite.blade.php文件,這file.i使用@include( 'newSite')line.but它無法正常工作。還當我把這個命令不工作都低於codes.please幫助我儘快

+0

當你調用@include(「newSite」)發生什麼事? –

+0

我的出門只顯示「新網站」Button.table不顯示在我的out.i要點擊新網站按鈕時,打開newSite.blade.php作爲彈出 – Harshan

+0

好吧,意味着你想顯示newSite.blade.php作爲一個彈出窗口? –

回答

0

試試這個:

$("#add").on('click',function(){ 
    $.ajax({ 
     method : 'get', 
     url : '{{ url("/getData") }}', 
     data : 
     { 
      var1 : val1 
     }, 
     success: function(response) 
     { 
      $('#site').html(response); // this response will contain the view returned from getData controller function 

      // Jquery UI dialog 
      $('#site').dialog({ 
       title : 'Your Title', 
       width : 400, 
       height : 350, 
       modal : true, 
       closeOnEscape: false 
      }); 
      $('.ui-widget-overlay').css('background', 'black'); 
     } 
    }) 
});