javascript - Keystone JS retrieve row ID in HTML table -
i'm having trouble update info :
i have array each line form. here looks in jade :
each info in infos form(method="post") input(type='hidden', name='action', value='save') td input(value='#{info.name.full}' disabled).form-control td input(value='#{info.field}' disabled).form-control td input(value='#{info.field1}' disabled).form-control td input(value='#{info.field2}' disabled).form-control td input(value='#{info.field3}' disabled).form-control td input(value='#{info.field4}' disabled).form-control td input(value='#{info.field5}' disabled).form-control td input(value='#{info.field6}' disabled).form-control td input(value='#{info.field7}' disabled).form-control td select(name='status').form-control option(value="")=(require) option(value="bla")="bla" option(value="blabla")="bla bla" option(value="blablabla")="bla bla bla" option(value="blablablabla")="bla bla bla bla" td button(type='submit').btn.btn-primary save
and i'd able save each line can't retrieve id when clicking on "save".
my javascript looks :
view.on('post', { action: 'save' }, function (next) { var application = new info.model(); var updater = application.getupdatehandler(req); updater.process(req.body, { flasherrors: true }, function (err) { if (err) { locals.validationerrors = err.errors; } else { locals.updatesubmitted = true; } next(); }); });
but guess don't understand how updatehandler works.
does have idea of how save row retrieving id ?
to solve it, added
input(type='hidden', name='id', value='#{info.id}')
just after
input(type='hidden', name='action', value='save')
then had access data :
console.log(req.body.id); console.log(req.body.item1);
and updated table :
info.model.findbyidandupdate(req.body.id, { $set: {field1: req.body.item1, field2: item2}}, function(err, info) { if (err) { next(err); } });
hope of you.
Comments
Post a Comment