Moved touch logic out of model into view.

View now updates using backbone events.
Jonathan Frederic 12 years ago committed by Jonathan Frederic
parent a2c951d9b0
commit b588a56f76

@ -45,19 +45,6 @@ function(widget_manager, underscore, backbone){
return Backbone.Model.apply(this);
},
update_other_views: function (caller) {
this.last_modified_view = caller;
this.save(this.changedAttributes(), {patch: true});
for (var view_index in this.views) {
var view = this.views[view_index];
if (view !== caller) {
view.update();
}
}
},
send: function (content, cell) {
@ -507,6 +494,12 @@ function(widget_manager, underscore, backbone){
this.model.send(content, this.cell);
},
touch: function () {
this.model.last_modified_view = this;
this.model.save(this.model.changedAttributes(), {patch: true});
},
update: function () {
if (this.model.get('visible') !== undefined) {
if (this.visible != this.model.get('visible')) {

@ -35,7 +35,7 @@ define(["notebook/js/widgets/base"], function(widget_manager){
.click(function(el) {
that.user_invoked_update = true;
that.model.set('value', that.$checkbox.prop('checked'));
that.model.update_other_views(that);
that.touch();
that.user_invoked_update = false;
})
.appendTo(this.$el);
@ -113,7 +113,7 @@ define(["notebook/js/widgets/base"], function(widget_manager){
handleClick: function(e) {
this.user_invoked_update = true;
this.model.set('value', ! $(e.target).hasClass('active'));
this.model.update_other_views(this);
this.touch();
this.user_invoked_update = false;
},
});

@ -76,7 +76,7 @@ define(["notebook/js/widgets/base"], function(widget_manager){
.attr('href', '#' + uuid)
.click(function(evt){
that.model.set("selected_index", index);
that.model.update_other_views(that);
that.touch();
})
.html('Page ' + index)
.appendTo(accordion_heading);
@ -151,7 +151,7 @@ define(["notebook/js/widgets/base"], function(widget_manager){
.appendTo(tab)
.click(function (e) {
that.model.set("selected_index", index);
that.model.update_other_views(that);
that.touch();
that.select_page(index);
});
this.containers.push(tab_text);

@ -103,7 +103,7 @@ define(["notebook/js/widgets/base"], function(widget_manager){
// Handle when a value is clicked.
handle_click: function (e) {
this.model.set('value', $(e.target).html(), this);
this.model.update_other_views(this);
this.touch();
},
});
@ -190,7 +190,7 @@ define(["notebook/js/widgets/base"], function(widget_manager){
// Handle when a value is clicked.
handle_click: function (e) {
this.model.set('value', $(e.target).val(), this);
this.model.update_other_views(this);
this.touch();
},
});
@ -272,7 +272,7 @@ define(["notebook/js/widgets/base"], function(widget_manager){
// Handle when a value is clicked.
handle_click: function (e) {
this.model.set('value', $(e.target).html(), this);
this.model.update_other_views(this);
this.touch();
},
});
@ -351,7 +351,7 @@ define(["notebook/js/widgets/base"], function(widget_manager){
// Handle when a value is clicked.
handle_click: function (e) {
this.model.set('value', $(e.target).html(), this);
this.model.update_other_views(this);
this.touch();
},
});

@ -119,7 +119,7 @@ define(["notebook/js/widgets/base"], function(widget_manager){
handleChanging: function(e) {
this.user_invoked_update = true;
this.model.set('value', e.target.value);
this.model.update_other_views(this);
this.touch();
this.user_invoked_update = false;
},
});
@ -173,7 +173,7 @@ define(["notebook/js/widgets/base"], function(widget_manager){
// Handles and validates user input.
handleChanging: function(e) {
this.model.set('value', e.target.value);
this.model.update_other_views(this);
this.touch();
},
// Handles text submition

Loading…
Cancel
Save