Last active
January 1, 2016 15:59
-
-
Save sjzabel/8167592 to your computer and use it in GitHub Desktop.
Using an Ember Array to proxy to an ArrayController
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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(); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Changed from a delete and save to an unloadRecord, because I neither need nor want it communicated the the backend webserver.