Created
October 17, 2014 04:20
-
-
Save davidbiehl/6b9acd493eca2056bdb7 to your computer and use it in GitHub Desktop.
ResourceEventRouter
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
App.module "Lib", (Lib, App, Backbone, Marionette, $, _)-> | |
class Lib.ResourceEventRouter extends App.Lib.EventRouter | |
constructor: (opts = {})-> | |
@resource = _.result(opts, "resource") || _.result(@, "resource") | |
opts.namespace = @resource | |
opts.events ||= {} | |
resourceEvents = | |
index : @resource | |
new : "#{@resource}/new" | |
show : (id)-> "#{@resource}/#{id}" | |
edit : (id)-> "#{@resource}/#{id}/edit" | |
opts.events = _.extend(resourceEvents, _.result(opts, "events")) | |
super(opts) | |
resource: false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment