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
}
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
.
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
}