2014-06-13 4 views
0

템플릿에 설정되지 않은 것 같은데 문제가 있습니다. 이것은 이전에는 발생하지 않았으며, 나는 무엇이 변경되는지를 모른다.내 서식 파일에 설정되어 있지 않습니까?

내 router.js

Router.map(function() { 
    this.route('gameRoom', { 
    path : '/game/:_id', 
    controller : GameRoomController 
    }); 

컨트롤러 내 detailsubmit.html에 따라서

GameRoomController = RouteController.extend({ 
    template : 'DetailsSubmit', 

    waitOn : function() { 
    return [ 
     Meteor.subscribe('gameList', this.params._id), 
     Meteor.subscribe('gameInfo', this.params._id), 
     Meteor.subscribe('hintsList', this.params._id), 
     Meteor.subscribe('guessList', this.params._id), 
     Meteor.subscribe('imagesList', this.params._id), 
     Meteor.subscribe('allUsers') 
//   Meteor.subscribe('scoreList', this.params._id) 
// stil in development will optimize this later 
    ]; 
    }, 

    data : function() { 
    return Games.findOne(this.params._id); 
    } 
}); 

내가 Games.find를 다음 템플릿 (SNIPPIT)

<template name='DetailsSubmit'> 
    {{#if isWaitingOnAction}} 
     <div id="profileInfo"> 
      <img src="http://placehold.it/90x90" alt=""/> 
     </div> 
    {{/if}} 
</template> 

을 입력 한 경우() .fetch() 올바르게 출력됩니다 :

_id: "5DDCNfWiBeHG4o7nQ" 
active: true 
finished: false 
players: Array[2] 
round: 0 
theBoss: "JLApNut5rTpRxoL9S" 
thePlayer: "o5aJETfWQTjEkZprf" 
__proto__: Object 

그래서 나는 다음 명령 중 하나하려고하면 내 템플릿이 제대로 작동 것이라고 기대 :

그리고 내 도우미 :

Template.DetailsSubmit.helpers({ 

isWaitingOnAction: function() { 
     console.log(this) // return Object {} 
     console.log(Games.findOne(this._id)) // returns undefined in console 
     console.log(Meteor.userId()); // returns correct userId 

    } 
}) 

내가 무슨 말이냐?

+0

당신은 관련이 기능을 게시 게시 할 수 있습니까? – user3374348

+0

아직 아무 것도 최적화하지 않았기 때문에 게시 기능이 매우 광범위합니다. 전체 게임 컬렉션을 게시하고 있습니다. Meteor.publish ('gameList', function() { return Games.find(); }}); – swennemen

+0

때때로'DetailsSubmit' 템플릿을 참조하지만 템플릿은'Detailsubmit'라고 불립니다. 실제로 그런가요? 아니면 여기에 게시 한 것입니까? – user3374348

답변

0

교체 :와

return Games.findOne(this.params._id); 

:

return Games.findOne({_id:this.params._id}); 
+0

불행히도 이것은 작동하지 않습니다. 동일한 결과를 산출합니다. – swennemen

+1

@Kuba :이 두 문장은 100 % 동일합니다. –

관련 문제