Hi all,
I’ve been looking into this a lot, and I’m trying to implement a notes system within a document that can be updated using x-editable. My problem is I can’t seem to be able to get the change to update the database.
I have tried using the $ operator and have searched for hours. I’m reasonably new to Meteor and am yet to be able to figure it out.
‘notes’ is a property in my document I am iterating over using #each, and I need to update specific notes
"notes" : [
{
"title" : "Tarog",
"description" : "Unu afejufav tic kobgib kefvotet capi noma ewrekos ut ubbar icodafo tawmuvdif gotib jiebi cesvuwmu fajumpu."
},
{
"title" : "Mume",
"description" : "We ritop fu kevi ene wob lozivdi vibil womazla saob nut sojade jet."
},
{
"title" : "Gupgaf",
"description" : "Gompaphug zosku wo tocca rif hab cuvlipve hi fig ugadiche lecrup zakija."
},
{
"title" : "Sesekepo",
"description" : "Mockus beud bor fahab hi cepmu du wunefepe piibpup bavcan solpojol ug dajsuni was wob hinar omtigra."
},
{
"title" : "Ej",
"description" : "Waapvi par jid pa bo vim vawvekra huwbuprup amoil ohu ihdeni zahgipri oseruful danaru."
}
]
Currently my JS:
Template.viewJob.onRendered(function () {
$('#textArea.editable').editable({
success: function (response, newValue) {
Jobs.update(
{"_id": parentID},
{
"$set": {
'notes.$.title': newValue
}
}
)
}
})
});
And this is the each loop:
{{#each notes}} <div class="well"> <h3 class="whichIndex">{{title}}</h3> <p id="textArea" class="editable" data-type="textarea" data-mode="inline" data-placeholder="Enter text" data-emptytext="Click to enter text" data-rows="4">{{description}}</p> </div> {{/each}}
Help would be greatly appreciated!