can
Version:
MIT-licensed, client-side, JavaScript framework that makes building rich web applications easy.
26 lines (21 loc) • 726 B
Markdown
Model.bind bind
can.Model.static
Listen for events on a Model class.
`can.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.
{can.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();
```
can.