diff --git a/js/models/lattice.js b/js/models/lattice.js index 89a72c2449a23cf61ed99503009447a35c51dbec..b8cc3f93c492b6c59779764ff383e364469d827d 100644 --- a/js/models/lattice.js +++ b/js/models/lattice.js @@ -158,8 +158,15 @@ Lattice = Backbone.Model.extend({ }, clearCells: function(){ - _.each(this.get("cells"), function(cell){ - if (cell.remove) cell.remove(); + _.each(this.get("cells"), function(cellLayer){ + _.each(cellLayer, function(cellCol){ + _.each(cellCol, function(cell){ + if (cell) { + cell.remove(); + } + }); + }); + }); this.set("cells", this.defaults.cells); this.set("numCells", 0);