vue-mc icon indicating copy to clipboard operation
vue-mc copied to clipboard

How to do a simple model update?

Open AJB99 opened this issue 4 years ago • 1 comments

Hi, I've read your docs a few times but I can't find the simplest example that illustrates how to modify any given model and have it updated on the server.

For example, let's say I have a Collection of Items, and I want to do this:

let item = ItemsCollection.models[0]
console.log(item.name) // Item One

item.name = 'Test'
console.log(item.name) // Test
item.update() // <-- this does nothing, no activity in the Network tab of my console, and my item is not updated via my API

I understand all the concepts very well, but nothing happens when I fire on any of the model methods.

Is there a basic tutorial or example or code sandbox somewhere that shows how to select a model, modify one of its attributes, and then update it so that it actually fires on my API endpoint?

Thanks in advance.

AJB99 avatar Mar 19 '20 22:03 AJB99

@AJB99 Have you tried using item.save() instead. From what I see in the docs that will make a request to update the model on the server.

d3chapma avatar Mar 25 '20 17:03 d3chapma