2016-06-28 1 views
0
@extends('layout') 

@section('content') 
    <div class="row"> 
     <div class="col-md-6 col-md-offset-3"> 
      <h1>{{ $id->title }}</h1> 

      <ul class="list-group"> 
       @foreach($id->notes as $note) 
        <li class="list-group-item"> 
         {{ $note->body }} 
         <span class="pull-right"> 
           <button href="/notes/{{ $note->id }}/edit" type="button" class="label label-default pull-xs-right">Edit</button> 
         </span> 
        </li> 
       @endforeach 
      </ul> 

      <hr> 
      <h3>Add a New Note</h3> 

      <div class="form-group"> 
       <form method="post" action="/cards/{{ $id->id }}/notes"> 
        <div class="form-group"> 
         <textarea name="body" class="form-control"></textarea> 
        </div> 
        <div class="form-group"> 
         <button type="submit" class="btn btn-primary">Add Note</button> 
        </div> 
       </form> 
      </div> 
     </div> 
    </div> 
@stop 

foreach 루프의 버튼에 올바른 링크/note/id/edit가 있습니다. 크롬에 입력하고 편집 페이지로 이동할 수 있습니다. 그러나 버튼은 거기에 향하지 않습니다. 클릭 애니메이션 만 보입니다. 왜 이럴 수 있니?라우라벨 버튼이 경로로 연결되지 않습니다.

답변

2

버튼 요소에 href 속성이 없으므로 이와 같은 링크 태그로 감쌀 수 있습니다. 이 방법이 가장 쉽습니다.

<a href="{{"/notes/". $note->id. "/edit"}}" > 
<button type="button" class="label label-default pull-xs-right">Edit</button 
></a> 

또는 양식 요소에 포장하고 액션 속성을 이와 같이 원하는 링크로 설정할 수 있습니다.

<Form method="get" action="{{"/notes/". $note->id. "/edit"}}"> 
<button type="submit" class="label label-default pull-xs-right">Edit</button> 
</Form> 

세 번째 방법은 javascript 및 onclick 수신기를 사용하는 것입니다.

+0

두 번째 제안을 사용했지만 버튼 유형을 '제출'으로 변경해야했습니다. 감사! – azdfg1

+0

언급 해 주셔서 감사합니다. 고정;) – user3786134