From 597c46c0e7a9b88c77ee79b2169f1a77889a64eb 2014-01-16 10:57:18 From: Jonathan Frederic Date: 2014-01-16 10:57:18 Subject: [PATCH] More fixes --- diff --git a/IPython/html/static/notebook/js/widgets/widget_bool.js b/IPython/html/static/notebook/js/widgets/widget_bool.js index bb78b96..8f3365f 100644 --- a/IPython/html/static/notebook/js/widgets/widget_bool.js +++ b/IPython/html/static/notebook/js/widgets/widget_bool.js @@ -25,30 +25,31 @@ define(["notebook/js/widgets/widget"], function(widget_manager){ .addClass('widget-hlabel') .appendTo(this.$el) .hide(); - var that = this; this.$checkbox = $('') .attr('type', 'checkbox') - .click(function(el) { - - // Calling model.set will trigger all of the other views of the - // model to update. - that.model.set('value', that.$checkbox.prop('checked'), {updated_view: this}); - that.touch(); - }) - .appendTo(this.$el); + .appendTo(this.$el) + .click($.proxy(this.handle_click, this)); this.$el_to_style = this.$checkbox; // Set default element to style this.update(); // Set defaults. }, + + handle_click: function() { + // Calling model.set will trigger all of the other views of the + // model to update. + var value = this.model.get('value'); + this.model.set('value', ! value, {updated_view: this}); + this.touch(); + }, update : function(options){ // Update the contents of this view // // Called when the model is changed. The model may have been // changed by another view or by a state update from the back-end. - if (options === undefined || options.updated_view != this) { - this.$checkbox.prop('checked', this.model.get('value')); + this.$checkbox.prop('checked', this.model.get('value')); + if (options === undefined || options.updated_view != this) { var disabled = this.model.get('disabled'); this.$checkbox.prop('disabled', disabled); @@ -70,11 +71,15 @@ define(["notebook/js/widgets/widget"], function(widget_manager){ var ToggleButtonView = IPython.DOMWidgetView.extend({ // Called when view is rendered. - render : function(){ + render : function() { + var that = this; this.setElement($('