2013-07-11 3 views
0

laravel에 새로운 Im가있어서 문제가 발생했습니다.Laravel, 데이터를 복제하지 않고 ajax를 사용하는 방법

public function index($type = null) 
{ 
    $items = $this->best(); 
    if (Request::ajax()) 
     return View::make('item_main', $items) -> with('items',$items); 
    else 
     $this->layout->content = View::make('main', $items) -> with('items',$items); 
} 

내 main.blade.php는 다음과 같습니다

아약스를 들어
@extends('layouts.master') 

@section('sidebar') 
    @parent 

    <p>This is appended to the master sidebar.</p> 
@stop 

@section('content') 
    @foreach ($items as $item) 
     {{$item->myth}} 
    @endforeach 
@stop 

, 내가없는 것은이 부분을 복제 할 않는 방법 만

@foreach ($items as $item) 
    {{$item->myth}} 
@endforeach 

를로드 할 필요 암호??

블레이드 내부의 뷰를로드하는 데 어려움이 있습니다. 내가 codeigniter에서했던 것.

고마워요!

+1

그렇습니다. @include ('view.name')'와 같이, [docs에 따라] (http://four.laravel.com/docs/templates#other-blade -control-structures) – Wrikken

+0

굉장! 고마워! –

+0

답으로 써야합니다. 또한 템플릿없이 블레이드 레이아웃을로드 할 수 있다는 통지를 추가 할 수 있습니다. –

답변

0
public function index($type = null) 
    { 
     $items = $this->best(); 
     if (Request::ajax()) 
      return View::make('item_main') -> with('items',$items); 
     else 
      $this->layout->content = View::make('main') -> with('items',$items); 
    } 

item_main.blade.php :

@foreach ($items as $item) 
    {{$item->myth}} 
@endforeach 

main.blade.php :

@extends('layouts.master') 

@section('sidebar') 
    @parent 

    <p>This is appended to the master sidebar.</p> 
@stop 

@section('content') 
    @include('item_main') 
@stop 

신용이 Wrikken로 이동합니다.

관련 문제