Skip to content

Instantly share code, notes, and snippets.

@sjzabel
Last active January 1, 2016 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sjzabel/8167592 to your computer and use it in GitHub Desktop.
Save sjzabel/8167592 to your computer and use it in GitHub Desktop.
Using an Ember Array to proxy to an ArrayController
"use strict";
App.set('flashProxy', Ember.A());
App.FlashController = Ember.ArrayController.extend({
itemController: 'flashObject'
,contentBinding: 'App.flashProxy'
});
App.FlashObjectController = Ember.ObjectController.extend({
actions: {
dismiss: function(flash) {
var flashProxy = App.get('flashProxy')
,newList = _(flashProxy).reject(
function(obj){
var fId = flash.get('id')
,oId = obj.get('id')
;
return oId == fId;.
}
)
;
App.set('flashProxy', newList);
// this is a private method, but it does exactly what I want to happen
// ala, removes it from the local store and doesn't send a delete to the webserver
flash.unloadRecord();
}
}
});
@sjzabel
Copy link
Author

sjzabel commented Dec 30, 2013

Changed from a delete and save to an unloadRecord, because I neither need nor want it communicated the the backend webserver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment