1
我在CoffeeScript上使用Backbone.js和Chaplin.js。我有一個挑戰。如何在路由視圖中獲取url參數?如何在視圖中獲取路徑url參數?
routes.coffee:
define ->
'use strict'
(match) ->
match "account/albums/:page", "accounts#albums"
define [
'chaplin'
'collections/albums'
'views/form_view'
'views/inline/album'
'text!template/account/_form_image.html'
'text!template/account/list_albums.html'
], (chaplin,
Albums,
FormView,
AlbumView,
formTemplate,
template
) ->
'use strict'
class AccountAlbums extends chaplin.CollectionView
collection: new Albums
itemView: AlbumView
template: template
containerMethod: 'html'
listSelector: '[data-placeholder=albums-tile]'
# TODO: understand how to get router arguments in the view
initialize: (options) ->
super
@on 'addedToDOM', => @collection.fetch()
# Need to something like this.
# But I do not know how to get it.
#@collection.fetch
# data:
# page: page