What if we remade bindEvents to have 1) a nicer API, and 2) auto-call stopListening?
Here's my thought: we could copy the backbone events object syntax:
, events: {
'click .mything': 'onMyThingClick'
}
, bbEvents: {
'change:key model': 'onModelChangeKey'
}
- keys would be split on a space, just as the
events hash does
- the first part of the key would be the event to listen to
- the second part of the key would be the object to listen to.
this. would be assumed. If omitted, it will listen on the view itself
- the value would be the name of the function to call
bindEvents would then become the method that parses this object. If over-ridden, (as we do now) things would behave as normal. Else, it just parses the bbEvents object. That makes this backward-compatible.
What if we remade
bindEventsto have 1) a nicer API, and 2) auto-callstopListening?Here's my thought: we could copy the backbone
eventsobject syntax:eventshash doesthis.would be assumed. If omitted, it will listen on the view itselfbindEventswould then become the method that parses this object. If over-ridden, (as we do now) things would behave as normal. Else, it just parses thebbEventsobject. That makes this backward-compatible.