destroy
can.Model.destroy
Destroy a resource on the server.
can.Model.destroy: function(id) -> deferred
If you provide a function, the Model will expect you to do your own AJAX requests.
Parameters
-
id
The ID of the resource to destroy.
Returns
{can.Deferred}
A Deferred that resolves to the destroyed model.
can.Model.destroy: "[METHOD] /path/to/resource"
If you provide a URL, the Model will send a request to that URL using the method specified (or DELETE if none is specified) when deleting an instance on the server. (See below for more details.)
Returns
{can.Deferred}
A Deferred that resolves to the destroyed model.
destroy(id) -> Deferred
is used by destroy remove a model instance from the server.Implement with a URL
You can implement destroy with a string like:
And use destroy to destroy it like:
This sends a
DELETE
request to/thing/destroy/1
.If your server does not support
DELETE
you can override it like:Implement with a function
Implement destroy with a function like:
Destroy just needs to return a deferred that resolves.