tbranyen/backbone.layoutmanager — pull request #224 by jugglinmike (2012-12-05 23:27:30+00:00)
Title: Rename 'append' to 'insert'

Submitting for consideration in v0.8 (#212).

The name `insert` is more generic: it does not imply the method by which
elements are added to the DOM. Since this method is intended to be
overridden with any arbitray insertion logic, the API should not suggest
what form that method takes.

For example, the following sample from the project documentation defines an `append` method that prepends content into the DOM. This feels a little awkward:

```javascript
var ListView = Backbone.View.extend({
beforeRender: function() {
// Append a new ItemView into the nested

.
this.insertView("ul", new ItemView({
// Prepend the element instead of append.
append: function(root, child) {
$(root).prepend(child);
}
}));
}
});
```

I think the API I'm proposing is a little more logical:

```javascript
var ListView = Backbone.View.extend({
beforeRender: function() {
// Append a new ItemView into the nested

.
this.insertView("ul", new ItemView({
// Prepend the element instead of append.
insert: function(root, child) {
$(root).prepend(child);
}
}));
}
});
```

This can be made backward-compatable with 0.7.2, but the code's a little ugly. I've included the necessary logic in a separate commit in case you're in to that sort of thing.​​