Skip to content

Instantly share code, notes, and snippets.

@robmonie
robmonie / ember data dependent createRecords
Last active December 20, 2015 01:59
WIP: Attempt at fixing the problem in ember data where creating multiple new records at once fails when one new record has a 'belongsTo' relationship to another. This approach is based around applying observers on the ids of records that other records 'belongTo' and only saving them when those records are saved and an id is returned from the ser…
createRecords: function(store, type, records) {
var adapter = this, serializer = this.serializer, initialRecordsToCreate = [];
if (get(this, 'bulkCommit') === false) {
records.forEach(function(record) {
var deferSave = false
record.eachRelationship(function(name, relationship) {
@robmonie
robmonie / gist:1224665
Created September 18, 2011 03:03
Sproutcore IE8, long running script dialog example
App = SC.Application.create({
NAMESPACE: 'App',
VERSION: '0.1.0',
store: SC.Store.create().from("App.Datasource")
});
App.Datasource = SC.DataSource.extend({
@robmonie
robmonie / gist:1215818
Created September 14, 2011 03:54
Sproutcore PagedArrayController
/**
* Provides paged content based on a larger result set.
*/
App.PagedArrayController = SC.ArrayProxy.extend({
content: [],
/**
* Subclasses should define the allResultsBinding to bind to the full set
* of results to be paged through