2012-08-10 86 views
1

路由我有一個的絕對網址:絕對URL與sammy.js

<a href="https://circleci.com/docs/configuration">configuration</a> 

我用Sammy.js路由,但不會將其路由。然而,它很高興地路由相同的URL的相對版本:

<a href="/docs/configuration">configuration</a> 

我怎樣才能使sammy路線的絕對版本以同樣的方式?

回答

0

你仍然可以使用哈希在href,即href="#ESPN"

然後捕獲與薩米路線,並使用location.assign方法加載新的URL或檢索文件:

Sammy(function() { 
    /* Top-bar navigation requests 
    */ 
    this.get("#:view", function() { 
     switch (this.params.view) {    
      case "ESPN": 
       location.assign("http://www.espn.com") 
       break;  
     }; 
    }); 

    /* Reporting Excel requests 
    */ 
    this.get("#Reporting/Excel/:type/:audience/:unitID/:departmentID", function() { 
     location.assign("Report/Excel?" + 
      "Type=" + this.params.type + "&" + 
      "Audience=" + this.params.audience + "&" + 
      "UnitID=" + this.params.unitID + "&" + 
      "DepartmentID=" + this.params.departmentID 
     ); 
    }); 
}).run();