Permalink
Browse files

Add appendChildInto function

  • Loading branch information...
bricestacey committed Apr 1, 2012
1 parent 8826f9c commit eb4a63d4fd52be4f41f5a89e23e51ab9f75116bf
@@ -27,6 +27,11 @@ _.extend(Support.CompositeView.prototype, Backbone.View.prototype, {
$(container).empty().append(view.el);
},
+ appendChildInto: function(view, container) {
+ this.renderChild(view);
+ container.append(view.el);
+ },
+
_leaveChildren: function() {
this.children.chain().clone().each(function(view) {
if (view.leave)
@@ -61,6 +61,18 @@ describe("Support.CompositeView", function() {
});
});
+ describe("#appendChildInto", function() {
+ it("renders child into the given element and appends content there", function() {
+ $("#test1").text("Append here!");
+
+ var view = new blankView({el: "#test"});
+ view.appendChildInto(new orangeView(), view.$("#test1");
+
+ expect($("test").text()).toEqual("");
+ expect($("test1").text()).toEqual("Append here!Orange!")
+ });
+ });
+
describe("#leave", function() {
it("removes elements and events when leave() is called", function() {
var view = new orangeView();

0 comments on commit eb4a63d

Please sign in to comment.