Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to do a simple model update? #142

Open
AJB99 opened this issue Mar 19, 2020 · 1 comment
Open

How to do a simple model update? #142

AJB99 opened this issue Mar 19, 2020 · 1 comment

Comments

@AJB99
Copy link

AJB99 commented Mar 19, 2020

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants