Sha256: 41f1c441a48d8f64b231784da331039b185ef7f44a0ebc50afd626b0c23ee9d9

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

class Application.Routers.PhotosRouter extends Backbone.Router
  initialize: (options) ->
    @photos = new Application.Collections.PhotosCollection()
    @photos.reset options.photos

  routes:
    "new"      : "newPhoto"
    "index"    : "index"
    "upload_index" : "upload_index"
    ":id/edit" : "edit"
    ":id"      : "show"
    ".*"        : "index"

  newPhoto: ->
    @view = new Application.Views.Photos.NewView(collection: @photos)
    $("#photos").html(@view.render().el)

  index: ->
    @view = new Application.Views.Photos.IndexView(photos: @photos)
    $("#photos").html(@view.render().el)

  upload_index: ->
    @view = new Application.Views.Photos.UploadIndexView(photos: @photos)
    $("#photos").html(@view.render().el)

  show: (id) ->
    photo = @photos.get(id)

    @view = new Application.Views.Photos.ShowView(model: photo)
    $("#photos").html(@view.render().el)

  edit: (id) ->
    photo = @photos.get(id)

    @view = new Application.Views.Photos.EditView(model: photo)
    $("#photos").html(@view.render().el)

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
mix-rails-0.12.2 mix-rails-albums/app/assets/javascripts/backbone/routers/photos_router.js.coffee
mix-rails-albums-0.12.2 app/assets/javascripts/backbone/routers/photos_router.js.coffee