2013-08-29 4 views
1

경로를 템플릿을 렌더링하지 않고 그냥 할 수 있습니까? Iron-Router 경로 임의의 방법

내가의 기능을 찾고있다 :하지 않으면

this.route({ 
    path: '/something/:info1/:info2', 
    method: function() { 
     // do something with this.params.info1 and this.params.info2 
     Router.go('elsewhere'); 
    }, 
}); 

,이 기능을 달성하는 방법은 무엇입니까?

+0

을 .. – Fabdrol

답변

0

물론 경로의 기본 동작을 무시할 수 있습니다. 경로의 기본 동작은 RouteController의 run 메서드입니다. 경로에 handler 옵션을 제공하여 0.5.4에서이 값을 대체합니다. dev 브랜치에서는 action 옵션 만 제공합니다. 기본 동작은 기본 템플릿을 렌더링 한 다음 모든 수율 템플릿을 적절한 위치에 렌더링합니다. 그러나 액션 함수는 템플릿을 전혀 렌더링하지 않는 것을 포함하여 원하는대로 할 수 있습니다. 나는 0.5.4 및 디바이스의 예를 보여 드리겠습니다 :

v0.5.4

this.route({ 
    path: '/something/:info/:info2', 
    handler: function() { 
    var info = this.params.info; 
    var info2 = this.params.info2; 
    this.redirect('elsewhere', { 
     //optional context object which could include params 
    }); 
    } 
}); 

dev에 지점 : 당신은 같이 location.href에서 인포 및 정보 2를 추출 할 수

this.route({ 
    path: '/something/:info/:info2', 
    action: function() { 
    var info = this.params.info; 
    var info2 = this.params.info2; 
    this.redirect('elsewhere', { 
     //optional context object which could include params 
    }); 
    } 
});