Skip to content

Instantly share code, notes, and snippets.

@fletcherm
Created January 19, 2012 00:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fletcherm/1636689 to your computer and use it in GitHub Desktop.
Save fletcherm/1636689 to your computer and use it in GitHub Desktop.
class AcademicServicesRouter extends Backbone.Router
routes:
'records': 'records'
'financial_aid': 'financial_aid'
'admissions': 'admissions'
initialize: ({@view}) =>
@view.bind 'records_selected', => @navigate('/records', true)
@view.bind 'financial_aid_selected', => @navigate('/financial_aid', true)
@view.bind 'admissions_selected', => @navigate('/admissions', true)
records: => @view.show_records()
financial_aid: => @view.show_financial_aid()
admissions: => @view.show_admissions()
class ViewThatSelectsRecordsForSomeReason extends Backbone.View
render: ->
# build @el
@$('.records-link').click => @trigger 'records_selected'
some_other_function: ->
@model.save(
success: => @trigger 'records_selected'
)
$(-> new AcademicServicesRouter(view: new ViewThatSelectsRecordsForSomeReason))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment