Added apply method to base model.

Allows model to propogate changes to all views except
for the one specified.
This commit is contained in:
Jonathan Frederic 2013-10-14 22:16:18 +00:00
parent 50213707ea
commit 3e36dd0c92

View File

@ -25,7 +25,18 @@ var IPython = (function (IPython) {
//-----------------------------------------------------------------------
// WidgetModel class
//-----------------------------------------------------------------------
var WidgetModel = Backbone.Model.extend({});
var WidgetModel = Backbone.Model.extend({
apply: function(sender) {
this.save();
for (var index in this.views) {
var view = this.views[index];
if (view !== sender) {
view.refresh();
}
}
}
});
//-----------------------------------------------------------------------
@ -214,7 +225,6 @@ var IPython = (function (IPython) {
clear_output : $.proxy(outputarea.handle_clear_output, outputarea)}
};
};
var model_json = model.toJSON();
var data = {sync_method: method, sync_data: model_json};
comm.send(data, callbacks);