javascript - Ember.js: each roundtrip to api adds new portion of the same values -


continue playing ember.js

i'm getting values api , trying display it. got data, when load route again (click on link) data appended list instead of replacing. how many times clicked - each time full list appended end.

the code big, don't realize part show actually.

maybe reason in key mapping? make this

app.adapter.map('semantic', {     primarykey: 'key' }); 

edit: jsfiddle link - http://jsfiddle.net/bug0r/94h3a/31/

click on , again on home.

there's issue datastore / restadapter model key setup.

try following :

ds.restadapter.reopen({   url: 'http://bug0r.apiary.io/api' });  app.adapter = ds.restadapter.extend({   serializer: ds.restserializer.extend({     primarykey: function (type){       return 'key';    }   }) });  app.store = ds.store.extend({     revision: 12,     adapter: app.adapter }); 

this gives datastore / restadapter vital information regarding primary key of records. without it has no way of knowing records has available internally , receiving rest api (so keeps on appending data coming rest api).

see forked fiddle

http://jsfiddle.net/ddewaele/ejcsq/


Comments