Просто поставьте контрольно-пропускной пункт, у меня тоже довольно большая таблица, и большинство ячеек доступны для редактирования, но я хочу нажать кнопку отправки и сохранить все значения во всех ячейках.
Вот то, что у меня сейчас есть:
$(".edit").focusout(function(){
//$("#sub").click(function() {
$(this).removeClass("editMode");
var id = this.id;
var split_id = id.split("_");
var field_name = split_id[0];
var edit_id = split_id[1];
var value = $(this).text();
$.ajax({
url: '/claim/store',
type: 'post',
data: { field:field_name, value:value, id:edit_id },
success:function(response){
console.log('Save successfully');
}
});
});
, которое работает, но работает только по одной ячейке за раз, и для сообщения ajax мне нужно отправить все, чтобы я мог закодировать его и сохранить в БД.
У меня есть это Laravel блейд-foreach:
@foreach($costItems as $key => $cost)
<tr>
<td>{{ $key }}</td>
<td colspan="6">{{ $cost}}</td>
<td contentEditable="true" class="edit" id="total_budget_{{ $key }}"></td>
<td contentEditable="true" class="edit" id="q1_{{ $key }}"></td>
<td contentEditable="true" class="edit" id="q2_{{ $key }}"></td>
<td contentEditable="true" class="edit" id="q3_{{ $key }}"></td>
<td contentEditable="true" class="edit" id="q4_{{ $key }}"></td>
<td contentEditable="true" class="edit" id="q5_{{ $key }}"></td>
<td contentEditable="true" class="edit" id="q6_{{ $key }}"></td>
<td contentEditable="true" class="edit" id="q7_{{ $key }}"></td>
<td contentEditable="true" class="edit" id="q8_{{ $key }}"></td>
<td contentEditable="true" class="edit" id="q9_{{ $key }}"></td>
<td contentEditable="true" class="edit" id="q10_{{ $key }}"></td>
<td contentEditable="true" class="edit" id="q11_{{ $key }}"></td>
<td contentEditable="true" class="edit" id="q12_{{ $key }}"></td>
<td contentEditable="true" class="edit" id="project_total_{{ $key }}"></td>
<td contentEditable="true" class="edit" id="variance_{{ $key }}"></td>
</tr>
Любая помощь с благодарностью, чтобы сохранить все отредактированные значения в одном go.