Sha256: c1f250ff6e5cb6161a262d9a7ba793341115c502c19bb2f5bc1a3206a0e61b37

Contents?: true

Size: 1.08 KB

Versions: 7

Compression:

Stored size: 1.08 KB

Contents

class <%= router_namespace %>Router extends Backbone.Router
  initialize: (options) ->
    @<%= plural_model_name %> = new <%= collection_namespace %>Collection()
    @<%= plural_model_name %>.reset options.<%= plural_model_name %>

  routes:
    "/new"      : "new<%= class_name %>"
    "/index"    : "index"
    "/:id/edit" : "edit"
    "/:id"      : "show"
    ".*"        : "index"

  new<%= class_name %>: ->
    @view = new <%= "#{view_namespace}.NewView(collection: @#{plural_name})" %>
    $("#<%= plural_name %>").html(@view.render().el)

  index: ->
    @view = new <%= "#{view_namespace}.IndexView(#{plural_name}: @#{plural_name})" %>
    $("#<%= plural_name %>").html(@view.render().el)

  show: (id) ->
    <%= singular_name %> = @<%= plural_name %>.get(id)

    @view = new <%= "#{view_namespace}.ShowView(model: #{singular_name})" %>
    $("#<%= plural_name %>").html(@view.render().el)

  edit: (id) ->
    <%= singular_name %> = @<%= plural_name %>.get(id)

    @view = new <%= "#{view_namespace}.EditView(model: #{singular_name})" %>
    $("#<%= plural_name %>").html(@view.render().el)

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
rails-backbone-0.7.1 lib/generators/backbone/scaffold/templates/router.coffee
rails-backbone-0.7.0 lib/generators/backbone/scaffold/templates/router.coffee
rails-backbone-0.6.1 lib/generators/backbone/scaffold/templates/router.coffee
rails-backbone-0.6.0 lib/generators/backbone/scaffold/templates/router.coffee
rails-backbone-0.6.0.rc lib/generators/backbone/scaffold/templates/router.coffee
rails-backbone-0.5.5 lib/generators/backbone/scaffold/templates/router.coffee
rails-backbone-sp-0.0.1 lib/generators/backbone/scaffold/templates/router.coffee