Skip to content

Commit 74527eb

Browse files
author
Derick Bailey
committed
removed the initialEvents from itemView so that it won't re-render the itemView when the collection is reset, by default
1 parent 6aad48a commit 74527eb

File tree

2 files changed

+2
-33
lines changed

2 files changed

+2
-33
lines changed

spec/javascripts/itemView.spec.js

-25
Original file line numberDiff line numberDiff line change
@@ -168,31 +168,6 @@ describe("item view", function(){
168168
});
169169
});
170170

171-
describe("when an item view's collection is reset", function(){
172-
var view;
173-
174-
beforeEach(function(){
175-
var collection = new Collection();
176-
view = new ItemView({
177-
template: "#collectionItemTemplate",
178-
collection: collection
179-
});
180-
181-
spyOn(view, "serializeData").andCallThrough();
182-
183-
collection.reset([ { foo: "bar" }, { foo: "baz" } ]);
184-
});
185-
186-
it("should serialize the collection", function(){
187-
expect(view.serializeData).toHaveBeenCalled();
188-
});
189-
190-
it("should render the template with the serialized collection", function(){
191-
expect($(view.el)).toHaveText(/bar/);
192-
expect($(view.el)).toHaveText(/baz/);
193-
});
194-
});
195-
196171
describe("when an item view has a model and collection, and is rendered", function(){
197172
var view;
198173

src/backbone.marionette.itemview.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,9 @@
77
Marionette.ItemView = Marionette.View.extend({
88
constructor: function(){
99
Marionette.View.prototype.constructor.apply(this, arguments);
10-
this.initialEvents();
11-
},
1210

13-
// Configured the initial events that the item view
14-
// binds to. Override this method to prevent the initial
15-
// events, or to add your own initial events.
16-
initialEvents: function(){
17-
if (this.collection){
18-
this.bindTo(this.collection, "reset", this.render, this);
11+
if (this.initialEvents){
12+
this.initialEvents();
1913
}
2014
},
2115

0 commit comments

Comments
 (0)