Clean up slickgrid events on removal
This commit is contained in:
@@ -51,6 +51,8 @@ my.SlickGrid = Backbone.View.extend({
|
|||||||
|
|
||||||
);
|
);
|
||||||
this.state = new recline.Model.ObjectState(state);
|
this.state = new recline.Model.ObjectState(state);
|
||||||
|
|
||||||
|
this._slickHandler = new Slick.EventHandler();
|
||||||
},
|
},
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
@@ -185,7 +187,7 @@ my.SlickGrid = Backbone.View.extend({
|
|||||||
this.grid.setSortColumn(column, sortAsc);
|
this.grid.setSortColumn(column, sortAsc);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.grid.onSort.subscribe(function(e, args){
|
this._slickHandler.subscribe(this.grid.onSort, function(e, args){
|
||||||
var order = (args.sortAsc) ? 'asc':'desc';
|
var order = (args.sortAsc) ? 'asc':'desc';
|
||||||
var sort = [{
|
var sort = [{
|
||||||
field: args.sortCol.field,
|
field: args.sortCol.field,
|
||||||
@@ -194,7 +196,7 @@ my.SlickGrid = Backbone.View.extend({
|
|||||||
self.model.query({sort: sort});
|
self.model.query({sort: sort});
|
||||||
});
|
});
|
||||||
|
|
||||||
this.grid.onColumnsReordered.subscribe(function(e, args){
|
this._slickHandler.subscribe(this.grid.onColumnsReordered, function(e, args){
|
||||||
self.state.set({columnsOrder: _.pluck(self.grid.getColumns(),'id')});
|
self.state.set({columnsOrder: _.pluck(self.grid.getColumns(),'id')});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -210,7 +212,7 @@ my.SlickGrid = Backbone.View.extend({
|
|||||||
self.state.set({columnsWidth:columnsWidth});
|
self.state.set({columnsWidth:columnsWidth});
|
||||||
});
|
});
|
||||||
|
|
||||||
this.grid.onCellChange.subscribe(function (e, args) {
|
this._slickHandler.subscribe(this.grid.onCellChange, function (e, args) {
|
||||||
// We need to change the model associated value
|
// We need to change the model associated value
|
||||||
//
|
//
|
||||||
var grid = args.grid;
|
var grid = args.grid;
|
||||||
@@ -233,7 +235,12 @@ my.SlickGrid = Backbone.View.extend({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
remove: function () {
|
||||||
|
this._slickHandler.unsubscribeAll();
|
||||||
|
Backbone.View.prototype.remove.apply(this, arguments);
|
||||||
|
},
|
||||||
|
|
||||||
show: function() {
|
show: function() {
|
||||||
// If the div is hidden, SlickGrid will calculate wrongly some
|
// If the div is hidden, SlickGrid will calculate wrongly some
|
||||||
|
|||||||
Reference in New Issue
Block a user