FiguredLimited / vue-mc

Models and Collections for Vue
https://vuemc.io
MIT License
626 stars 98 forks source link

How to do a simple model update? #142

Open AJB99 opened 4 years ago

AJB99 commented 4 years ago

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.

d3chapma commented 4 years ago

@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.