Skip to content

Instantly share code, notes, and snippets.

@dannoso
Created November 22, 2013 18:41
Show Gist options
  • Save dannoso/7604820 to your computer and use it in GitHub Desktop.
Save dannoso/7604820 to your computer and use it in GitHub Desktop.
I think the problem is that when you do that:
PlacesLocal.add(record.data);
There's an id field with a value in record.data. Hence, the record won't be considered new. It won't be considered modified either, because it has not be modified, and it won't be considered deleted either (the explaination is left as an exercice to the reader).
In other words, for the store, there's nothing to sync. Mission complete.
Here's the code of getNewRecords, that is used in the sync method:
function() {
return this.data.filterBy(function(item) {
// only want phantom records that are valid
return item.phantom === true && item.isValid();
}).items;
}
I suppose you've guessed what you need to do by now, but let me be voluble:
var recordsData = store.getRange().map(function(record) { return record.data }),
newRecords = PlacesLocal.add(recordsData);
Ext.each(newRecords, function(record) {
record.phantom = true;
});
// Now it should have plenty of work!
PlacesLocal.sync();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment