Frage

Is there a way to examine active bindings on a Marionette view?
The bindings are created in the controller as follows:

// controllers/custom_controller.js

this.customView.bind("some:custom:event", this.customEventHandler, this);

The custom event is triggered within the view:

// views/custom_view.js

onSomething: function() {
  this.trigger("some:custom:event");
}

I would like to check whether this.customView has a event handler for some:custom:event.

War es hilfreich?

Lösung

this.customView._events is an object of the bound events. So to check if the event exists:

if (this.customView._events["some:custom:event"]) {
  //do something
} 
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top