thedersen/backbone.validation — Issue #24: events question
Author: davisford
Created: 2012-02-22 04:19:39+00:00
State: open

Hi, consider the following view code:

MyView = Backbone.Views.extend({
events: {
"validated": "validated",
"validated:valid": "valid",
"validated:invalid": "invalid"
}
initialize: function() { Backbone.Validation.bind(this); },
validated: function() { console.log('validated'); },
valid: function() { console.log('valid'); },
invalid: function() { console.log('invalid'); }
});

If I force validation on the model, the "validated" event fires and my handler is called, but the "valid" and "invalid" sub event handlers are not. If I explicitly bind to them on the model, then they do fire. I have to add this:

Backbone.Validation.bind(this, { valid: this.valid, invalid: this.invalid });

and then my handlers are called. Why is this? I'd prefer to specify it in the events object and assign a handler for all three.