@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。我可以将其输入chrome并转到编辑页面。但是,按钮不会在那里。我只看到点击动画。为什么会这样?
答案 0 :(得分:2)
Button元素没有href
属性,因此您可以将其包装在这样的链接标记中。这是最简单的方法
<a href="{{"/notes/". $note->id. "/edit"}}" >
<button type="button" class="label label-default pull-xs-right">Edit</button
></a>
或者您可以将其包装在表单元素中,并将action属性设置为您想要的链接。
<Form method="get" action="{{"/notes/". $note->id. "/edit"}}">
<button type="submit" class="label label-default pull-xs-right">Edit</button>
</Form>
第三种方式是使用javascript和onclick监听器。