1 回答
TA贡献1815条经验 获得超10个赞
您需要定位行 ( tr) 并切换它,直接标记行会更容易吗
@foreach ($projects as $project)
<tr class="row1 @if($project->status == 4)cancelled @endif">
<td>
<form action="/projects/plan" method="post" id="statusForm{{$project->id}}">
@csrf
<!-- If status is 1 an unchecked checkbox -->
@if ($project->status == "1")
<input name="id" type="hidden" value="{{$project->id}}" >
<input type="radio"
name="status"
onchange="document.getElementById('statusForm{{$project->id}}').submit()"
data-placement="top"
title="project is requested"
data-toggle="hoverText"
>
<!-- If status is 2 an checked checkbox -->
@elseif ($project->status == "2")
<input type="radio"
name="status"
data-toggle="hoverText"
data-placement="top"
title="project is accepted"
checked
>
<!-- If status is 4 project is cancelled -->
@else
<span class="fas fa-ban red" data-toggle="hoverText" data-placement="top" title="project is cancelled"></span>
@endif
</form>
</td>
<td>{{$project->name}}</td>
<td>{{$project->contact_name}}</td>
<td>{{$project->contact_email}}</td>
<td><a href="/projects/{{$project->id}}/edit" class="btn btn-secondary btn-sm" role="button">project Details</a></td>
</tr>
@endforeach
</tbody>
然后使用 JavaScript 将其与 class 切换cancelled。
$(document).ready(function(){
$(".showhide").click(function(e){
e.preventDefault();
$('tr.cancelled').toggle();
});
});
添加回答
举报