2016-08-12 60 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'); 
     } 
    }) 
});