I'm trying to append rows to a table but it don't pass <tr>
and <td>
, it's wired. Pass all without this two tags.
My jquery code is that:
$.get('/remove-day-travel/'+id, function(data)
{
$('#travelTable tbody').html('');
$('#travelTable tbody').append(data);
addDayTravel();
removeDayTravel();
});
My controller:
public function removeDayTravel($id)
{
$intervention = DB::table('interventionDays')->select('interventionId')->where('id', $id)->first();
//DB::table('interventionDays')->where('id', $id)->delete();
$travelHours = DB::table('interventionDays')
->where('interventionId', $intervention->interventionId)
->orderBy('day', 'ASC')
->get();
return view('current-dayTravel', compact('travelHours'));
}
And my view is that:
@if(count($travelHours) > 0)
<?php $count = 1; ?>
@foreach ($travelHours as $key => $value)
<input type="hidden" name="day-travel-id[{{$count}}]" value="{{$value->id}}">
<input type="hidden" name="day-travel-remove[{{$count}}]" value="0">
<tr>
<td><label>Dia {{$count}}:</label></td>
<td><label>Ida</label></td>
<td class="@if ($errors->has('hour-day-1[' . $count . ']')) has-error @endif">
{!! Form::text('hour-day-1[' . $count . ']', $value->morningStart , ['class' => 'form-control travelGoStartHour', 'placeholder'=> '']) !!}
</td>
<td class="@if ($errors->has('hour-day-2[{{$count}}]')) has-error @endif">
{!! Form::text('hour-day-2[' . $count. ']', $value->morningEnd, ['class' => 'form-control travelGoEndHour', 'placeholder'=> '']) !!}
</td>
<td>
<label>Volta</label>
</td>
<td class="@if ($errors->has('hour-day-3[' . $count . ']')) has-error @endif">
{!! Form::text('hour-day-3[' . $count . ']', $value->afternoonStart, ['class' => 'form-control travelBackStartHour', 'placeholder'=> '']) !!}
</td>
<td class="@if ($errors->has('hour-day-4[' . $count . ']')) has-error @endif">
{!! Form::text('hour-day-4[' . $count . ']', $value->afternoonEnd, ['class' => 'form-control travelBackEndHour', 'placeholder'=> '']) !!}
</td>
<td>
{!! Form::checkbox('dinner[' . $count . ']', 0,$value->dinner) !!}
</td>
<td>
{!! Form::checkbox('stay[' . $count . ']', 0,$value->stay) !!}
</td>
<td>
@if($key == count($travelHours) -1)
<i class="icon-plus-circled add-new-day-travel" title="Adicionar Novo dia" data-id="1"></i>
@endif
</td>
<td>
@if($key == count($travelHours) -1)
<i class="icon-cancel remove-day-travel" title="Remover dia" data-id="{{$count}}" data-record="{{$value->id}}"></i>
@endif
</td>
</tr>
<?php $count += 1; ?>
@endforeach
@endif
I don't understand why? What I'm doing wrong?
Thank you