我的面板体内的按钮不起作用。这是代码:
<div class="panel-body">
<table border="3">
<!-- <div id="tray"></div> -->
@forelse($carts as $cart)
<div class="row">
<div class="col-md-1">{{$cart->id}}</div>
<div class="col-md-3">{{$cart->name}}</div>
<div class="col-md-4">
<div class="row clearfix">
<div class="col-md-1">
<form action="/restaurant/minus" method="POST">
<input type="hidden" name="trayid" id="trayid" value="{{$cart->id}}">
<input type="hidden" name="trayprice" id="trayprice" value="{{$cart->price}}">
<button type="submit" class="btn btn-xs btn-primary" style="border-radius: 50%;" id="{{$menu->id}}"><i class="fa fa-minus" aria-hidden="true"></i></button>
</form>
</div>
<div class="col-md-4">
<input type="number" min="1" value="{{$cart->quantity}}" style="width:40px;">
</div>
<div class="col-md-1">
<form action="/restaurant/plus" method="post">
<input type="hidden" name="trayid" id="trayid" value="{{$cart->id}}">
<input type="hidden" name="trayprice" id="trayprice" value="{{$cart->price}}">
<button type="submit" class="btn btn-xs btn-primary" style="border-radius: 50%"><i class="fa fa-plus" aria-hidden="true"></i></button>
</form>
</div>
</div>
</div>
<div class="col-md-2">
<input type="hidden" name="trayprice" value="{{$cart->price}}">
</div>
<div class="col-md-1">
<form action="/restaurant/delete" method="post">
<input type="text" name="deleteid" id="deleteid" value="{{$cart->id}}">
<button type="submit" class="btn btn-xs btn-danger" style="border-radius: 50%;"><i class="fa fa-trash" aria-hidden="true"></i></button>
</form>
</div>
</div>
@empty
@endforelse
</table>
</div>
与此同时,我的面板标题中的按钮有效,它只是清除了身体。
<div class="panel-heading">
<div class="row clearix">
<form class="col-md-12" method="POST" action="/restaurant/cleartray">
{{ csrf_field() }}
<p class="pull-left">Tray</p>
<button type="submit" class="btn btn-danger btn-xs pull-right"><i class="fa fa-eraser" aria-hidden="true"></i> Clear</button>
</form>
</div>
</div>
结构是否有任何问题导致按钮无法工作?
P.S:它甚至没有达到路线目标。它没有刷新或类似的东西。这就像按钮本身没有反应一样。
编辑:我发现表格中的按钮一旦进入前景循环就不起作用。
答案 0 :(得分:0)
我认为您可以更改路线操作,如:
<form action="/restaurant/plus" method="post">
以强>
<form action="{{ url('restaurant/plus') }}" method="post">
希望这对你有用!
答案 1 :(得分:0)
我通过字面调试得到了答案,哈哈。
事实证明,在表格标签内部使用表单标签并不顺利。所以我拿出了桌子标签。 (我不记得我为什么一开始就拥有它)
Aaaaand瞧!它奏效了!