We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot easily listen to completion changes without listening to all collections or models.
There should be a mechanism to bubble events from component to course.
Proposal:
// core/js/modelEvent.js define(function() { var ModelEvent = Backbone.Controller.extend({ type: null, target: null, value: null, bubbles: true, deepPath: null, target: null, timeStamp: null, initialize: function(type, target, value) { this.type = type; this.target = target; this.value = value; this.deepPath = [target]; }, stopPropagation: function() { this.bubbles = false; }, addPath: function(target) { this.deepPath.unshift(target); } }); return ModelEvent; }); // core/js/model/adaptModel.js define([ 'core/js/adapt', 'core/js/modelEvent', ], function (Adapt, ModelEvent) { var AdaptModel = Backbone.Model.extend({ bubblingEvents: [ 'change:_isComplete', 'change:_isInteractionComplete' ], setupChildListeners: function() { this.listenTo(children, { "all": this.onAll, "bubble": this.bubble }); } onAll: function(type, model, value) { if (!_.contains(this.bubblingEvents, type)) return; var event = new ModelEvent(type, model, value); this.bubble(event); }, bubble: function(event) { if (!event.bubbles) return; event.addPath(this); this.trigger("bubble:"+event.type, event); this.trigger("bubble", event); } }); return AdaptModel; }); // example Adapt.course.on("bubble:change:_isComplete", function(event) { /* * event.type = "change:_isComplete"; * event.stopPropagation(); // stop event from bubbling * event.bubbles = true/false; // has stopPropagation been called? * event.deepPath = [grandParent, parent, target]; // path of bubble * event.target; // instance on which event occurred * event.value; // value of event * */ });
The text was updated successfully, but these errors were encountered:
oliverfoster
No branches or pull requests
Subject of the issue
Cannot easily listen to completion changes without listening to all collections or models.
Expected behaviour
There should be a mechanism to bubble events from component to course.
Proposal:
The text was updated successfully, but these errors were encountered: