Skip to content

Instantly share code, notes, and snippets.

@joegaudet
Created September 7, 2010 18:59
Show Gist options
  • Save joegaudet/568857 to your computer and use it in GitHub Desktop.
Save joegaudet/568857 to your computer and use it in GitHub Desktop.
createRecord: function(store, storeKey) {
var ret = NO;
if (SC.kindOf(store.recordTypeFor(storeKey), this.get('baseRecord'))) {
SC.Request.postUrl(this.get('createUrl')).header({
'Accept': 'application/json'
}).json().notify(this, 'didCreateRecord', store, storeKey).send(store.readDataHash(storeKey));
ret = YES;
}
return ret;
},
didCreateRecord: function(response, store, storeKey) {
if (SC.ok(response)) {
var dataHash = response.get('body').content;
store.dataSourceDidComplete(storeKey, dataHash, dataHash['guid']);
} else store.dataSourceDidError(storeKey, response);
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment