Skip to content

Commit 94c3e49

Browse files
committed
JS: Story only calls methods on collection if present.
1 parent 64cb943 commit 94c3e49

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

‎app/public/js/app.js‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ var Story = Backbone.Model.extend({
2626
open: function() {
2727
if (!this.get("keep_unread")) this.set("is_read", true);
2828
if (this.shouldSave()) this.save();
29-
30-
this.collection.closeOthers(this);
31-
this.collection.unselectAll();
32-
this.collection.setSelection(this);
29+
30+
if(this.collection){
31+
this.collection.closeOthers(this);
32+
this.collection.unselectAll();
33+
this.collection.setSelection(this);
34+
}
3335

3436
this.set("open", true);
3537
this.set("selected", true);
@@ -52,7 +54,7 @@ var Story = Backbone.Model.extend({
5254
},
5355

5456
select: function() {
55-
this.collection.unselectAll();
57+
if(this.collection) this.collection.unselectAll();
5658
this.set("selected", true);
5759
},
5860

0 commit comments

Comments
 (0)