|
190 | 190 | },
|
191 | 191 | created () {
|
192 | 192 | var self = this;
|
193 |
| - eventBus.$on('updateWidth', function(width) { |
| 193 | +
|
| 194 | + // Accessible refernces of functions for removing in beforeDestroy |
| 195 | + self.updateWidthHandler = function(width) { |
194 | 196 | self.updateWidth(width);
|
195 |
| - }); |
196 |
| - eventBus.$on('compact', function(layout) { |
| 197 | + }; |
| 198 | +
|
| 199 | + self.compactHandler = function(layout) { |
197 | 200 | self.compact(layout);
|
198 |
| - }); |
199 |
| - eventBus.$on('setDraggable', function(isDraggable) { |
| 201 | + }; |
| 202 | +
|
| 203 | + self.setDraggableHandler = function(isDraggable) { |
200 | 204 | self.isDraggable = isDraggable;
|
201 |
| - }); |
202 |
| - eventBus.$on('setResizable', function(isResizable) { |
| 205 | + }; |
| 206 | +
|
| 207 | + self.setResizableHandler = function(isResizable) { |
203 | 208 | self.isResizable = isResizable;
|
204 |
| - }); |
205 |
| - eventBus.$on('setRowHeight', function(rowHeight) { |
| 209 | + }; |
| 210 | +
|
| 211 | + self.setRowHeightHandler = function(rowHeight) { |
206 | 212 | self.rowHeight = rowHeight;
|
207 |
| - }); |
| 213 | + }; |
| 214 | +
|
| 215 | + self.directionchangeHandler = (direction) => { |
| 216 | + var direction = (document.dir != undefined) ? |
| 217 | + document.dir : |
| 218 | + document.getElementsByTagName("html")[0].getAttribute("dir"); |
| 219 | + this.rtl = (direction == "rtl"); |
| 220 | + this.compact(); |
| 221 | + }; |
| 222 | +
|
| 223 | + eventBus.$on('updateWidth', self.updateWidthHandler); |
| 224 | + eventBus.$on('compact', self.compactHandler); |
| 225 | + eventBus.$on('setDraggable', self.setDraggableHandler); |
| 226 | + eventBus.$on('setResizable', self.setResizableHandler); |
| 227 | + eventBus.$on('setRowHeight', self.setRowHeightHandler); |
| 228 | + eventBus.$on('directionchange', self.directionchangeHandler); |
| 229 | +
|
208 | 230 | /*eventBus.$on('setColNum', function(colNum) {
|
209 | 231 | self.cols = colNum;
|
210 | 232 | });*/
|
211 | 233 | var direction = (document.dir !=undefined) ?
|
212 | 234 | document.dir :
|
213 | 235 | document.getElementsByTagName("html")[0].getAttribute("dir");
|
214 | 236 | this.rtl = (direction == "rtl");
|
215 |
| - eventBus.$on('directionchange', (direction) => { |
216 |
| - var direction = (document.dir != undefined) ? |
217 |
| - document.dir : |
218 |
| - document.getElementsByTagName("html")[0].getAttribute("dir"); |
219 |
| - this.rtl = (direction == "rtl"); |
220 |
| - this.compact(); |
221 |
| - }); |
| 237 | + }, |
| 238 | + beforeDestroy: function(){ |
| 239 | + //Remove listeners |
| 240 | + eventBus.$off('updateWidth', self.updateWidthHandler); |
| 241 | + eventBus.$off('compact', self.compactHandler); |
| 242 | + eventBus.$off('setDraggable', self.setDraggableHandler); |
| 243 | + eventBus.$off('setResizable', self.setResizableHandler); |
| 244 | + eventBus.$off('setRowHeight', self.setRowHeightHandler); |
| 245 | + eventBus.$off('directionchange', self.directionchangeHandler); |
222 | 246 | },
|
223 | 247 | mounted: function() {
|
224 | 248 | this.cols = this.$parent.colNum;
|
|
0 commit comments