Created
July 24, 2013 22:03
-
-
Save monokrome/6075034 to your computer and use it in GitHub Desktop.
Bread crumbs in Marionette.
This file contains 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
# This is a bread crumb. It stores the URL, view | |
# state, whatever. | |
class BreadCrumb extends Model | |
class BreadCrumbs extends Collection | |
model: BreadCrumb | |
# Views for displaying it | |
class BreadCrumbView extends Marionette.ItemView | |
template: 'breadcrum/templates/crumb' | |
tagName: 'li' | |
class BreadCrumbsView extends Marionette.CollectionView | |
itemView: BreadCrumbView | |
id: 'document-bread-crumbs' | |
tagName: 'ul' | |
className: 'inline' | |
# This controller represents your appliance. | |
class BreadCrumbController extends BaseController | |
initialize: -> | |
Backbone.history.on 'route', @updateBreadCrumbs | |
@crumbs = new BreadCrumbs | |
@view = new BreadCrumbsView | |
collection: @crumbs | |
@application.layout.currentView.breadCrumbs.show @view | |
updateBreadCrumbs: -> | |
# Manage @crumbs here. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment