Skip to content

Instantly share code, notes, and snippets.

@mitchellsimoens
Created July 18, 2012 18:33
Show Gist options
  • Save mitchellsimoens/3137945 to your computer and use it in GitHub Desktop.
Save mitchellsimoens/3137945 to your computer and use it in GitHub Desktop.
Extending Ext.plugin.PullRefresh
/**
* You were close except since you had override, it was going to try and override all Ext.plugin.PullRefresh.
*
* Here is an example at extending it, you are making a new class. So instead of creating Ext.plugin.PullRefresh, you would use mobuy.plugin.PullRefresh.
*
* You would put this in the app/plugin/PullRefresh.js file and then you can require this class and it will be loaded.
*/
Ext.define('mobuy.plugin.PullRefresh', {
extend : 'Ext.plugin.PullRefresh',
alias : 'plugin.mobuy-pullrefresh',
onLatestFetched: function(operation) {
var store = this.getList().getStore(),
oldRecords = store.getData(),
newRecords = operation.getRecords(),
length = newRecords.length,
toInsert = [],
newRecord, oldRecord, i;
for (i = 0; i < length; i++) {
newRecord = newRecords[i];
oldRecord = oldRecords.getByKey(newRecord.getId());
if (oldRecord) {
oldRecord.set(newRecord.getData());
} else {
toInsert.push(newRecord);
}
oldRecord = undefined;
}
//line edited, add instead of insert
store.add(toInsert);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment