mirror of
https://github.com/jupyter/notebook.git
synced 2024-12-27 04:20:22 +08:00
Fixed checkbox click event handler
This commit is contained in:
parent
9ce2a9eeca
commit
fc6cb0231f
@ -14,8 +14,15 @@ require(["notebook/js/widget"], function(){
|
|||||||
.addClass('widget-hlabel')
|
.addClass('widget-hlabel')
|
||||||
.appendTo(this.$el)
|
.appendTo(this.$el)
|
||||||
.hide();
|
.hide();
|
||||||
|
var that = this;
|
||||||
this.$checkbox = $('<input />')
|
this.$checkbox = $('<input />')
|
||||||
.attr('type', 'checkbox')
|
.attr('type', 'checkbox')
|
||||||
|
.click(function(el) {
|
||||||
|
that.user_invoked_update = true;
|
||||||
|
that.model.set('value', that.$checkbox.prop('checked'));
|
||||||
|
that.model.update_other_views(that);
|
||||||
|
that.user_invoked_update = false;
|
||||||
|
})
|
||||||
.appendTo(this.$el);
|
.appendTo(this.$el);
|
||||||
|
|
||||||
this.update(); // Set defaults.
|
this.update(); // Set defaults.
|
||||||
@ -38,15 +45,6 @@ require(["notebook/js/widget"], function(){
|
|||||||
return IPython.WidgetView.prototype.update.call(this);
|
return IPython.WidgetView.prototype.update.call(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
events: {"change input" : "handleChanged"},
|
|
||||||
|
|
||||||
// Handles and validates user input.
|
|
||||||
handleChanged: function(e) {
|
|
||||||
this.user_invoked_update = true;
|
|
||||||
this.model.set('value', $(e.target).prop('checked'));
|
|
||||||
this.model.update_other_views(this);
|
|
||||||
this.user_invoked_update = false;
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
IPython.notebook.widget_manager.register_widget_view('CheckboxView', CheckboxView);
|
IPython.notebook.widget_manager.register_widget_view('CheckboxView', CheckboxView);
|
||||||
|
Loading…
Reference in New Issue
Block a user