2016-06-28 8 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のリンクがあります。私はそれをクロームに入力して編集ページに行くことができます。しかし、ボタンはそこに向かない。私はちょうどクリックアニメーションを見る。これはなぜでしょうか?Laravelボタンがルートにリンクしていません

答えて

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> 

第3の方法は、javascriptとonclickリスナーを使用することです。

+0

私は2番目の提案を使用しましたが、ボタンタイプを 'submit'に変更する必要がありました。ありがとう! – azdfg1

+0

に感謝します。一定 ;) – user3786134

関連する問題