Last active
January 3, 2016 05:39
-
-
Save rsoares/8417313 to your computer and use it in GitHub Desktop.
Insert LayoutManager views into different positions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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