Make sure backbone events fire.

If $el is set to something else, make sure all the backbone machinery
knows about the new DOM element.
This commit is contained in:
Jonathan Frederic 2013-11-20 21:36:03 +00:00
parent b7e1797fd2
commit f16f1d6537
5 changed files with 4 additions and 5 deletions

View File

@ -23,7 +23,7 @@ define(["notebook/js/widget"], function(widget_manager){
// Called when view is rendered. // Called when view is rendered.
render : function(){ render : function(){
this.$el = $('<div />') this.$el
.addClass('widget-hbox-single'); .addClass('widget-hbox-single');
this.$label = $('<div />') this.$label = $('<div />')
.addClass('widget-hlabel') .addClass('widget-hlabel')
@ -74,7 +74,6 @@ define(["notebook/js/widget"], function(widget_manager){
render : function(){ render : function(){
this.$el this.$el
.html(''); .html('');
this.$button = $('<button />') this.$button = $('<button />')
.addClass('btn') .addClass('btn')
.attr('type', 'button') .attr('type', 'button')

View File

@ -30,6 +30,7 @@ define(["notebook/js/widget"], function(widget_manager){
that.model.set('clicks', that.model.get('clicks') + 1); that.model.set('clicks', that.model.get('clicks') + 1);
that.model.update_other_views(that); that.model.update_other_views(that);
}); });
this._ensureElement();
this.update(); // Set defaults. this.update(); // Set defaults.
}, },

View File

@ -21,7 +21,7 @@ define(["notebook/js/widget"], function(widget_manager) {
var ContainerView = IPython.WidgetView.extend({ var ContainerView = IPython.WidgetView.extend({
render: function(){ render: function(){
this.$el = $('<div />') this.$el =
.addClass('widget-container'); .addClass('widget-container');
}, },

View File

@ -23,6 +23,7 @@ define(["notebook/js/widget"], function(widget_manager){
render: function(){ render: function(){
this.$el = $('<div />', {id: IPython.utils.uuid()}) this.$el = $('<div />', {id: IPython.utils.uuid()})
.addClass('accordion'); .addClass('accordion');
this._ensureElement();
this.containers = []; this.containers = [];
}, },
@ -102,7 +103,6 @@ define(["notebook/js/widget"], function(widget_manager){
var TabView = IPython.WidgetView.extend({ var TabView = IPython.WidgetView.extend({
render: function(){ render: function(){
this.$el = $('<div />');
var uuid = IPython.utils.uuid(); var uuid = IPython.utils.uuid();
var that = this; var that = this;
this.$tabs = $('<div />', {id: uuid}) this.$tabs = $('<div />', {id: uuid})

View File

@ -22,7 +22,6 @@ define(["notebook/js/widget"], function(widget_manager){
// Called when view is rendered. // Called when view is rendered.
render : function(){ render : function(){
this.$el = $('<div />');
this.update(); // Set defaults. this.update(); // Set defaults.
}, },