mercredi 24 décembre 2014

What is the best way to remove an item from an array in Ember (not using Ember Data)

I use an ajax call to get my model. Once I have my model I need to make changes to it and save those changes.


In the version of ember I had been using it was easy, I just used an ajax call to get my model, make changes and then post my model to save it.


Now when I need to make a change to my model, I have to do an Ember.set(model, "title", "New Title Text");


How could I remove an item from an array?



"gallery" : [
{
"_id" : ObjectId("5499f6cea66483d54bad151d"),
"description" : "X",
"title" : "Test1234",
"meta" : {
"position" : 0
},
"src" : {
"large" : "http://ift.tt/1B1NSzm",
"medium" : "http://ift.tt/1B1NSzm",
"small" : "http://ift.tt/1B1NSiU"
}
},
{
"description" : "",
"title" : "",
"_id" : ObjectId("549ae002b078644011254066"),
"meta" : {
"position" : 1
},
"src" : {
"large" : "http://ift.tt/16QCpti",
"medium" : "http://ift.tt/16QCpti",
"small" : "http://ift.tt/16QCptq"
}
},
{
"description" : "",
"title" : "",
"_id" : ObjectId("549ae002b078644011254065"),
"meta" : {
"position" : 3
},
"src" : {
"large" : "http://ift.tt/1B1NSj2",
"medium" : "http://ift.tt/1B1NSj2",
"small" : "http://ift.tt/16QCn4N"
}
},
{
"description" : "",
"title" : "",
"_id" : ObjectId("549ae05eb078644011254067"),
"meta" : {
"position" : 2
},
"src" : {
"large" : "http://ift.tt/1B1NSzw",
"medium" : "http://ift.tt/1B1NSzw",
"small" : "http://ift.tt/1B1NVeu"
}
}
]




Aucun commentaire:

Enregistrer un commentaire