jeudi 17 janvier 2019

Get Model from Router and then update it

So, at certain point in my application I have a route that retrieves a model, lets say user model, that looks like this:

routes/users.js
model(params) {
    return this.get('store').findRecord('user', params.id);
}

Then, at some point in the template i've got this:

templates/users.js

...
<button onclick=>Save Changes</button>

Which should allow me to change users name and save it.

The saveChanges action in controller looks like this:

controllers/users.js
saveChanges(){
    this.get('model').save();
}

Now the problem is that it seems that the input from the template is not bounding the value with records attribute, whenever the input value changes it does not changes the models value.

The second problem is that this.get('model').save(); doesn't even sends a patch to the server.

Everything else just works fine, its just this that doesn't work. Does anyone have a clue what could be wrong here?

Thanks!




Aucun commentaire:

Enregistrer un commentaire