ビデオ プレーヤーを含むテンプレートがあります。ヘルパーを使用して、mongo ドキュメントからビデオ ソースを取得します。これがどのように見えるかです:
ヘルパー:
'currentItemUrl' : function() {
//I only have one project. Is there a better/cleaner way to obtain it than the one below?
var currentProject = Projects.find().fetch()[0];
//the function below will create an instance of videojs or update the current one (set the new source)
loadPlayer();
//I return the source url if I have one
return currentProject.setup.player.item_loaded.url?currentProject.setup.player.item_loaded.url:"";
}
HTML は次のようになります。
<video id="video_player" class="video-js vjs-default-skin" controls preload="auto"
width = "{{videoWidth}}" height="videoHeight"
poster="{{currentItemPoster}}">
<source id="mp4" src="{{currentItemUrl}}" type='video/mp4' />
<source id="webm" src="" type='video/webm' />
<source id="ogg" src="" type='video/ogg' />
</video>
質問
Projects
別のテンプレートでコレクションを更新するときにヘルパーが再実行されるようにするにはどうすればよいですか? を使用しているのでCollection.find()
、すでに反応するべきではありませんか?