From 3e36dd0c92435d24b9bf84aa013261e620c30d42 Mon Sep 17 00:00:00 2001 From: Jonathan Frederic Date: Mon, 14 Oct 2013 22:16:18 +0000 Subject: [PATCH] Added apply method to base model. Allows model to propogate changes to all views except for the one specified. --- IPython/html/static/notebook/js/widget.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/IPython/html/static/notebook/js/widget.js b/IPython/html/static/notebook/js/widget.js index ce293abd1..f4d2b5bf9 100644 --- a/IPython/html/static/notebook/js/widget.js +++ b/IPython/html/static/notebook/js/widget.js @@ -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);