2014-01-27 1 views
0

내가 설정이 중첩 된 경로가 다시로드 행위". 이 시점에서 다시로드하면 이 정상적으로 작동하여 모든 레코드를 다시로드합니다. 문제는 하위 경로로 전환 할 때입니다. 인덱스 페이지에서 /actions/[action-id]으로 전환하면 페이지가 예상대로로드되지만 해당 페이지에서 페이지를 다시로드하면 (즉, 작업에 대한 로컬 상태가 사라짐) 페이지가로드되면 실패합니다. 여기 모델 후크 실패 브라우저

모델 상기 ActionsActionRoute에 후크입니다 : 모두 사용 사례에서 흥미롭게

model: function(params) { 
    console.log(params); 
    return this.store.find('Action',params.id); 
} 

- 브라우저에서 새로 고침을 누르면 처음이 URL 로 이동하는 경우 -이 모델 후크를 실행

Object {id: "action-id", queryParams: Object} 

속성이 정확히 동일하게 나타납니다 아직 다시로드 시나리오에서 나는 오류를 제공합니다 :

,369 및 콘솔 문의 결과를 제공

Error while loading route: TypeError: Cannot read property 'id' of undefined at DS.Store.Ember.Object.extend.push (http://my.server.com/myApp/javascripts/vendor.js:71617:77)

누구나 내가이 잡아 넘겨 줄 수있게 도와 줄 수 있습니까?

답변

1

Routerresource 대신 route으로 중첩 경로를 지정합니다. 엠버 가이드에서

:

NOTE: You should use this.resource for URLs that represent a noun, and this.route for URLs that represent adjectives or verbs modifying those nouns. For example, in the code sample above, when specifying URLs for posts (a noun), the route was defined with this.resource('posts'). However, when defining the new action (a verb), the route was defined with this.route('new').

귀하의 경우는, /action/:id자원 아닌 상위 자원에서 경로 나타냅니다. 다음과 같이 코드를 변경하는 것이 좋습니다.

this.resource('actions', { path: '/actions' }, function() { 
    this.resource("action", {path: ':id'}); 
}); 
+0

감사합니다. 문서로 돌아가서 이것이 흑백인지 확인해야합니다 ... 특히 "로드 중", "오류"및 "색인"과 같은 경로는 때로는 너무 많은 실험이 될 때가 있습니다. 통치하는 규칙이 명확한 지 확인하십시오. 어쨌든 경감 님과 도움이 많은 사람들에게 감사드립니다. :) – ken

+0

물론이 게시물에 관심이있을 수 있습니다 : http://darthdeus.github.io/blog/2013/02/01/ember-dot-js-router-and-template-naming-convention/ –

관련 문제