can-model
Version:
26 lines (21 loc) • 718 B
Markdown
can-model.bind bind
can-model.static
Listen for events on a Model class.
`Model.bind(eventType, handler)`
{String} eventType The type of event. It must be
`"created"`, `"updated"`, `"destroyed"`.
{function} handler A callback function
that gets called with the event and instance that was
created, destroyed, or updated.
{Model} The model constructor function.
`bind(eventType, handler(event, instance))` listens to
__created__, __updated__, __destroyed__ events on all
instances of the model.
```
Task.bind("created", function(ev, createdTask){
this //-> Task
createdTask.attr("name") //-> "Dishes"
})
new Task({name: "Dishes"}).save();
```