Just hit a roadblock, I have a table quite a big table too, and most cells are editable, but I want to click a submit button and save all the values in the all the cells.
Here's what I currently have:
$(".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');
}
});
});
Which works but only does one cell at a time and fo the ajax post I need to send everything through so I can encode it and save to the db.
I have this is a Laravel blade foreach:
@foreach($costItems as $key => $cost)
<tr>
<td></td>
<td colspan="6"></td>
<td contentEditable="true" class="edit" id="total_budget_"></td>
<td contentEditable="true" class="edit" id="q1_"></td>
<td contentEditable="true" class="edit" id="q2_"></td>
<td contentEditable="true" class="edit" id="q3_"></td>
<td contentEditable="true" class="edit" id="q4_"></td>
<td contentEditable="true" class="edit" id="q5_"></td>
<td contentEditable="true" class="edit" id="q6_"></td>
<td contentEditable="true" class="edit" id="q7_"></td>
<td contentEditable="true" class="edit" id="q8_"></td>
<td contentEditable="true" class="edit" id="q9_"></td>
<td contentEditable="true" class="edit" id="q10_"></td>
<td contentEditable="true" class="edit" id="q11_"></td>
<td contentEditable="true" class="edit" id="q12_"></td>
<td contentEditable="true" class="edit" id="project_total_"></td>
<td contentEditable="true" class="edit" id="variance_"></td>
</tr>
Any help greatly appreciated in order to save all the edited values in one go.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire