Skip to content

Instantly share code, notes, and snippets.

@monokrome
Created July 24, 2013 22:03
Show Gist options
  • Save monokrome/6075034 to your computer and use it in GitHub Desktop.
Save monokrome/6075034 to your computer and use it in GitHub Desktop.
Bread crumbs in Marionette.
# 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