jQuery.Model.prototype.bind  attribute     

Binds to events on this model instance. Typically you'll bind to an attribute name. Handler will be called every time the attribute value changes. For example:

$.Model("School")
var school = new School();
school.bind("address", function(ev, address){
  alert('address changed to '+address);
})
school.attr("address","1124 Park St");

You can also bind to attribute errors.

$.Model("School",{
  setName : function(name, success, error){
    if(!name){
       error("no name");
    }
    return error;
  }
})
var school = new School();
school.bind("error.name", function(ev, mess){
   mess // -> "no name";
})
school.attr("name","");

You can also bind to created, updated, and destroyed events.

© Jupiter IT - JavaScriptMVC Training and Support