覆盖该partial
函数并执行以下操作jQuery#find
:
Backbone.LayoutManager.configure({
partial: function(root, name, el, append) {
// If no selector is specified, assume the parent should be added to.
var $root = name ? $(root).find(name) : $(root);
// Use the append method if append argument is true.
// Set the element to append to be the first child.
this[append ? "append" : "html"]($root, $(el).children().first());
}
});
可以在全局(以上)或本地实例上覆盖此方法。
您还需要调整afterRender
以使用新元素:
Backbone.LayoutView.extend({
afterRender: function() {
this.setElement(this.el.firstChild);
this.delegateEvents();
}
});
更多信息在这里:http ://tbranyen.github.com/backbone.layoutmanager/#configuration/defaults