Clean up slickgrid events on removal
This commit is contained in:
parent
93637a7b0b
commit
ea8c8f1a5b
@ -51,6 +51,8 @@ my.SlickGrid = Backbone.View.extend({
|
||||
|
||||
);
|
||||
this.state = new recline.Model.ObjectState(state);
|
||||
|
||||
this._slickHandler = new Slick.EventHandler();
|
||||
},
|
||||
|
||||
events: {
|
||||
@ -185,7 +187,7 @@ my.SlickGrid = Backbone.View.extend({
|
||||
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 sort = [{
|
||||
field: args.sortCol.field,
|
||||
@ -194,7 +196,7 @@ my.SlickGrid = Backbone.View.extend({
|
||||
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')});
|
||||
});
|
||||
|
||||
@ -210,7 +212,7 @@ my.SlickGrid = Backbone.View.extend({
|
||||
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
|
||||
//
|
||||
var grid = args.grid;
|
||||
@ -233,7 +235,12 @@ my.SlickGrid = Backbone.View.extend({
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
},
|
||||
|
||||
remove: function () {
|
||||
this._slickHandler.unsubscribeAll();
|
||||
Backbone.View.prototype.remove.apply(this, arguments);
|
||||
},
|
||||
|
||||
show: function() {
|
||||
// If the div is hidden, SlickGrid will calculate wrongly some
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user