2012-06-05 85 views
1

這裏是我的路由結構的一個例子:高級路由與功能分組

 
routes:{ 
"*actions" : "defaultHandler", //some default handler 
//handlers for all pages 
"Page1" : "Page1", 
. . . . . . . . . . 
"PageN" : "PageN", 

//and now I have a module, with it's own pages, and routes for it has similar look: 
"Module/Page01" : "Page01", 
. . . . . . . . . . 
"Module/PageNN" : "PageNN", 

/* and now I have to do some task for all navigations 
    to the Module and I am trying to make this: */ 

"Module/*path" : "moduleHandler" 

    /* and it's not working, because in this case on navigate, for example 
    to the page "Module/Page01" only moduleHandler responding, not Page01 handler */ 
} 

這樣。我需要這兩個處理程序來回應。無法找到此千方百計文檔

回答

1

你需要的東西是這樣的:https://github.com/FLOChip/backbone_router_filter 但是,當然,這只是一個例子,你應該實現將取決於路線上過濾。隨時詢問你是否遇到困難。

更新:我剛剛發現這個:https://github.com/angelo0000/backbone_filters。如果我明白這正是你想要的。

var R = Backbone.Router.extend({ 
    routes: { 
     "page1": "page1", 
     "pageN": "pageN", 
     "module/page01": "page01", 
     "module/pageNN": "pageNN", 
     "*actions" : "defaultHandler" 
    }, 

    before: { 
     '^module/': 'moduleFilter' 
    } 
    //... 
}); 
+0

好的解決方案,就像瑞士刀。謝謝! – elisium

+0

但我發現了一些限制,нопожалуйста:)。 – theotheo