How to update multiple input with the same name using backbone.js. I just want to update each input per td with their corresponding doc_id using jquery. ANy suggestion or help...
Here is my html code:
<td>
<input type="hidden" value="1" name="doc_id"/>
<input type="text" class="abc" name="docs_nos[]" id="inputDocs_nos" value=""/>
<input type="text" class="abc" name="date_issued[]" id="inputstart" placeholder="mm/dd/yyy" value=""/>
<input type="text" class="abc" name="date_expired[]" id="inputend" placeholder="mm/dd/yyy" value=""/>
<input type="text" class="abc" name="remaks[]" id="inputRemaks" value="" />
</td>
<td>
<input type="hidden" value="2" name="doc_id"/>
<input type="text" class="abc" name="docs_nos[]" id="inputDocs_nos" value=""/>
<input type="text" class="abc" name="date_issued[]" id="inputstart" placeholder="mm/dd/yyy" value=""/>
<input type="text" class="abc" name="date_expired[]" id="inputend" placeholder="mm/dd/yyy" value=""/>
<input type="text" class="abc" name="remaks[]" id="inputRemaks" value="" />
</td>
Here is my javascript code:
saveDocs: function(e) {
var that = this
var d = array;
$.map($('input.abc, select.abc').serializeArray(), function(n, i) {
d[n['name']] = n['value'];
});
documents = new Documents();
documents.set('id', $('input[type=hidden]').val());
documents.save(d, {
success: function (model, response) {
alert = new AlertView({type: 'success', message: 'Update success.'});
alert.render();
},
error: function (model, response) {
alert = new AlertView({type: 'error', message: response});
alert.render();
}
});
}