• function

bind can.Model.bind


Listen for events on a Model class.

can.Model.bind(eventType, handler)


  1. eventType {String}

    The type of event. It must be "created", "udpated", "destroyed".

  2. handler {function()}

    A callback function that gets called with the event and instance that was created, destroyed, or updated.



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();