我目前有一个表单,可以在提交时将数据存储到数据库中。我现在有其他代码:
'click .addmore': function(event){
$('.addmore').before('<label>Other Appearance: </label><input class="additionalAppearances" type="text"/>')
}
这将添加其他字段。如何将这些附加值存储到数据库?
顺便说一句:这就是我已经存储了我的价值观的方式。我要为此存储其他值:
var publisherVar = event.target.publisher.value.toLowerCase().replace(' ','');
var superheroVar = event.target.superhero.value;
var firstAppearance = event.target.appearance.value;
var coverImage = event.target.coverImage.value;
var imgDescript = event.target.imgDescript.value;
ComicsList.insert({
publisher: publisherVar,
superhero: superheroVar,
appearance: firstAppearance,
coverImage: coverImage,
imgDescript: imgDescript
});
任何帮助,将不胜感激。谢谢。
最佳答案
将插入内容更改为更新。
ComicsList.update({_id:this._id}{$set{publisher: publisherVar,
superhero: superheroVar,
appearance: firstAppearance,
coverImage: coverImage,
imgDescript: imgDescript
}});
this._id,
是指当前文档,如果您在{{#each}}
中包含提交内容,它将起作用