diff --git a/IPython/html/static/notebook/js/widgetmanager.js b/IPython/html/static/notebook/js/widgetmanager.js index c8a5fb5..2526640 100644 --- a/IPython/html/static/notebook/js/widgetmanager.js +++ b/IPython/html/static/notebook/js/widgetmanager.js @@ -38,8 +38,8 @@ // Register already-registered widget model types with the comm manager. var that = this; - _.each(WidgetManager._model_types, function(value, key) { - that.comm_manager.register_target(value, $.proxy(that._handle_comm_open, that)); + _.each(WidgetManager._model_types, function(model_type, model_name) { + that.comm_manager.register_target(model_name, $.proxy(that._handle_comm_open, that)); }); }; diff --git a/IPython/html/static/notebook/js/widgets/widget.js b/IPython/html/static/notebook/js/widgets/widget.js index f4cf76a..7a8a2aa 100644 --- a/IPython/html/static/notebook/js/widgets/widget.js +++ b/IPython/html/static/notebook/js/widgets/widget.js @@ -86,12 +86,13 @@ function(WidgetManager, Underscore, Backbone){ apply_update: function (state) { // Handle when a widget is updated via the python side. + var that = this; _.each(state, function(value, key) { - this.key_value_lock = [key, value]; + that.key_value_lock = [key, value]; try { - this.set(key, this._unpack_models(value)); + that.set(key, that._unpack_models(value)); } finally { - this.key_value_lock = null; + that.key_value_lock = null; } }); }, @@ -154,7 +155,7 @@ function(WidgetManager, Underscore, Backbone){ } // Only sync if there are attributes to send to the back-end. - if (attr.length > 0) { + if (_.size(attrs) > 0) { var callbacks = options.callbacks || {}; if (this.pending_msgs >= this.msg_throttle) { // The throttle has been exceeded, buffer the current msg so @@ -203,8 +204,9 @@ function(WidgetManager, Underscore, Backbone){ return value.id; } else if (value instanceof Object) { var packed = {}; + var that = this; _.each(value, function(sub_value, key) { - packed[key] = this._pack_models(sub_value); + packed[key] = that._pack_models(sub_value); }); return packed; } else { @@ -216,8 +218,9 @@ function(WidgetManager, Underscore, Backbone){ // Replace model ids with models recursively. if (value instanceof Object) { var unpacked = {}; + var that = this; _.each(value, function(sub_value, key) { - unpacked[key] = this._unpack_models(sub_value); + unpacked[key] = that._unpack_models(sub_value); }); return unpacked; } else { @@ -366,9 +369,10 @@ function(WidgetManager, Underscore, Backbone){ var css = this.model.get('_css'); if (css === undefined) {return;} + var that = this; _.each(css, function(css_traits, selector){ // Apply the css traits to all elements that match the selector. - var elements = this._get_selector_element(selector); + var elements = that._get_selector_element(selector); if (elements.length > 0) { _.each(css_traits, function(css_value, css_key){ elements.css(css_key, css_value); diff --git a/IPython/html/static/notebook/js/widgets/widget_float.js b/IPython/html/static/notebook/js/widgets/widget_float.js index 8485336..1c98e50 100644 --- a/IPython/html/static/notebook/js/widgets/widget_float.js +++ b/IPython/html/static/notebook/js/widgets/widget_float.js @@ -50,10 +50,11 @@ define(["notebook/js/widgets/widget"], function(WidgetManager){ // JQuery slider option keys. These keys happen to have a // one-to-one mapping with the corrosponding keys of the model. var jquery_slider_keys = ['step', 'max', 'min', 'disabled']; + var that = this; _.each(jquery_slider_keys, function(key, i) { - var model_value = this.model.get(key); + var model_value = that.model.get(key); if (model_value !== undefined) { - this.$slider.slider("option", key, model_value); + that.$slider.slider("option", key, model_value); } }); diff --git a/IPython/html/static/notebook/js/widgets/widget_int.js b/IPython/html/static/notebook/js/widgets/widget_int.js index af0c3c7..42b779f 100644 --- a/IPython/html/static/notebook/js/widgets/widget_int.js +++ b/IPython/html/static/notebook/js/widgets/widget_int.js @@ -49,10 +49,11 @@ define(["notebook/js/widgets/widget"], function(WidgetManager){ // JQuery slider option keys. These keys happen to have a // one-to-one mapping with the corrosponding keys of the model. var jquery_slider_keys = ['step', 'max', 'min', 'disabled']; + var that = this; _.each(jquery_slider_keys, function(key, i) { - var model_value = this.model.get(key); + var model_value = that.model.get(key); if (model_value !== undefined) { - this.$slider.slider("option", key, model_value); + that.$slider.slider("option", key, model_value); } }); diff --git a/IPython/html/static/notebook/js/widgets/widget_selection.js b/IPython/html/static/notebook/js/widgets/widget_selection.js index fab10c0..570aa3b 100644 --- a/IPython/html/static/notebook/js/widgets/widget_selection.js +++ b/IPython/html/static/notebook/js/widgets/widget_selection.js @@ -67,10 +67,11 @@ define(["notebook/js/widgets/widget"], function(WidgetManager){ var items = this.model.get('values'); var $replace_droplist = $('