Skip to content

Commit

Permalink
Build app.
Browse files Browse the repository at this point in the history
  • Loading branch information
rgrove committed May 25, 2011
1 parent 2d8d8c6 commit 473e02c
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 51 deletions.
35 changes: 23 additions & 12 deletions build/app/app-debug.js
Expand Up @@ -127,23 +127,27 @@ Y.Model = Y.extend(Model, Y.Base, {
// -- Public Methods -------------------------------------------------------

/**
Deletes this model on the server and removes it from its containing list, if
Destroys this model instance and removes it from its containing list, if
any.
This method delegates to the `sync()` method to perform the actual delete
operation, which is an asynchronous action. Specify a _callback_ function to
be notified of success or failure.
If `options['delete']` is `true`, then this method also delegates to the
`sync()` method to delete the model from the persistence layer, which is an
asynchronous action. Provide a _callback_ function to be notified of success
or failure.
@method delete
@method destroy
@param {Object} [options] Sync options. It's up to the custom sync
implementation to determine what options it supports or requires, if any.
implementation to determine what options it supports or requires, if
any.
@param {Boolean} [options.delete=false] If `true`, the model will be
deleted via the sync layer in addition to the instance being destroyed.
@param {callback} [callback] Called when the sync operation finishes.
@param {Error|null} callback.err If an error occurred, this parameter will
contain the error. If the sync operation succeeded, _err_ will be
`null`.
@chainable
**/
'delete': function (options, callback) {
destroy: function (options, callback) {
var self = this;

// Allow callback as only arg.
Expand All @@ -152,13 +156,20 @@ Y.Model = Y.extend(Model, Y.Base, {
options = {};
}

this.sync('delete', options, function (err) {
if (!err && self.list) {
self.list.remove(self);
function finish(err) {
if (!err) {
self.list && self.list.remove(self);
Model.superclass.destroy.call(self);
}

callback && callback.apply(null, arguments);
});
}

if (options['delete']) {
this.sync('delete', options, finish);
} else {
finish();
}

return this;
},
Expand Down Expand Up @@ -505,7 +516,7 @@ Y.Model = Y.extend(Model, Y.Base, {
Override this method to provide a custom persistence implementation for this
model. The default just calls the callback without actually doing anything.
This method is called internally by `load()`, `save()`, and `delete()`.
This method is called internally by `load()`, `save()`, and `destroy()`.
@method sync
@param {String} action Sync action to perform. May be one of the following:
Expand Down
4 changes: 2 additions & 2 deletions build/app/app-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 473e02c

Please sign in to comment.