2014-09-18 4 views
0

내 응용 프로그램에는 두 가지 중요한 모델 인 ContentCollection과 ContentItem이 있습니다.무제한 선택적 매개 변수가있는 백본 경로

각 ContentCollection에는 많은 ContentCollections 및 ContentItem이 있습니다. ContentCollections를 폴더로, ContentItems를 파일로 생각할 수 있습니다. 따라서 이러한 종류의 구조가 가능해야합니다.

- ContentCollection 
    \- ContentCollection 
     \- ContentCollection 
     \- ContentCollection 
      \- Item 
      \- Item 
     \- ContentCollection 
     \- Item 
- ContentCollection 
    \- Item 
    \- Item 
- Item 
- Item 

ContentCollections 및 ContentItems에 대한 표시 경로를 만들고 싶습니다.

/home/collections/{id} 

및 ...

/home/items/{id} 

및 ...

/home/collections/{id}/collections/{id}/collections/{id} 

및 ...

/home/collections/{id}/collections/{id}/collections/{id}/items/{id} 

등등.

백본 경로에서 이러한 종류의 중첩을 우아하게 처리 할 수있는 간단한 방법이 있습니까?

답변

3

당신은 아무것도 일치하는 포괄 경로를, 필요 ... 다음

var MyRouter = Backbone.Router.extend({ 
    '*collection': 'showCollection' 
}); 

그리고

당신의 행동 분석의 약간 :

Controller = { 
    showCollection: function (query) { 
    segments = query.split('/') 
    } 
}