spine.jsevent-binding

Spinejs: binding events for nested controllers


I'm having a problem with nested controller like this

For example, I have controller A

class A extends Spine.Controller
  events:
   'click .foo' : 'handle_bar'

Then I create two instance of A like this

a = new A
b = new A
a.append b

When I click on .foo inside b, then b.handle_bar is called. But a.handle_bar is called as well.

How to prevent that problem?

Thanks!


Solution

  • because you end up nesting b inside of a with a.append b events that happen in b are also happening in a. It would probably be a bad idea for Spine controllers in general to stop propagation of events to prevent this, but you could implement that solution on b if you needed to.