Skip to content

Instantly share code, notes, and snippets.

@rsoares
Last active January 3, 2016 05:39
Show Gist options
  • Save rsoares/8417313 to your computer and use it in GitHub Desktop.
Save rsoares/8417313 to your computer and use it in GitHub Desktop.
Insert LayoutManager views into different positions
var MyView = Backbone.View.extend({
// ...
/* Override insert function. */
insert: function(root, child) {
var $lastView = root.find( ".foo" ).last(),
$lastBar = root.find( ".foo.bar" ).last();
if( $lastView.length ) {
child.insertAfter( $lastView );
} else if( $lastBar.length ) {
child.insertAfter( $lastBar );
} else {
root.append( child );
}
}
// ...
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment