Created
February 5, 2016 16:26
-
-
Save Mariusio/e74073b5466b803d0af8 to your computer and use it in GitHub Desktop.
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
// Option 1, does not work if there is more than one visualization | |
// Error: | |
/*TypeError: Cannot read property 'get' of undefined | |
at charts.js:87 | |
at exports.default._emberMetalMixin.Mixin.create.forEach (ember.debug.js:33050) | |
at charts.js:86 | |
at tryCatch (ember.debug.js:52858) | |
at Object.invokeCallback (ember.debug.js:52873) | |
at ember.debug.js:54999 | |
at ember.debug.js:31434 | |
at Queue.invoke (ember.debug.js:327) | |
at Object.Queue.flush (ember.debug.js:391) | |
at Object.DeferredActionQueues.flush (ember.debug.js:192)*/ | |
chart.get('visualizations').then((visualizations) => { | |
visualizations.forEach((visualization) => { | |
this.store.unloadRecord(visualization); | |
}); | |
}); | |
// Option 2, does not work if there is more than one visualization | |
// Error: | |
/*TypeError: Cannot read property 'get' of undefined | |
at charts.js:87 | |
at exports.default._emberMetalMixin.Mixin.create.forEach (ember.debug.js:33050) | |
at charts.js:86 | |
at tryCatch (ember.debug.js:52858) | |
at Object.invokeCallback (ember.debug.js:52873) | |
at ember.debug.js:54999 | |
at ember.debug.js:31434 | |
at Queue.invoke (ember.debug.js:327) | |
at Object.Queue.flush (ember.debug.js:391) | |
at Object.DeferredActionQueues.flush (ember.debug.js:192)*/ | |
chart.get('visualizations').then((visualizations) => { | |
visualizations.forEach((visualization) => { | |
var id = visualization.get('id'); | |
var modelName = visualization.get('constructor.modelName'); | |
var record = this.store.peekRecord(modelName, id); | |
this.store.unloadRecord(record); | |
}); | |
}); | |
// Option 3, works, but feels like a strange workaround | |
chart.get('visualizations').then((visualizations) => { | |
var arr = []; | |
visualizations.forEach((visualization) => { | |
var id = visualization.get('id'); | |
var modelName = visualization.get('constructor.modelName'); | |
var newArr = [] | |
newArr.pushObject(modelName); | |
newArr.pushObject(id); | |
arr.pushObject(newArr); | |
}); | |
arr.forEach((element) => { | |
var record = this.store.peekRecord(element[0], element[1]); | |
this.store.unloadRecord(record); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment