ember.js - Defining buildURL depending on what properties have changed -


i redefine buildurl depending on properties changed on same model. example, if status changed, put route, , if subuser changed, put route.

example :

this.store.find('conversation', conv.id).then(function(conversation){     conversation.set('status', 'opened');     conversation.save();                     }); 

this use put route , :

this.store.find('conversation', this.get('selectedconv').id).then(function(conversation){     conversation.set('subuser', subuser);     conversation.set('url', subuser.get('email'));     conversation.save(); }); 

and use put route tho changes made on same model. happening in controller.

you need customize conversation adapter, urlforupdaterecord method.

the original method looks this:

urlforupdaterecord: function(id, modelname, snapshot) {   return this._buildurl(modelname, id); }, 

in method, need examine snapshot , adjust url accordingly.

the latest version of ember data has introduced changedattributes property. seems need.

good luck!


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -