私は次のようにいくつかのコードを持って、次のMeteor Template events、イベントの原因となったオブジェクトを取得する方法は?
この状況でmyapp.js
Template.problem.events = {
'click .problem-text' : function() {
var user_id = Session.get('user_id');
// how to get problem_id of clicked item?
Router.gotoProblem(user_id, problem_id);
}
};
でmyapp.html
<template name="problems">
<div class="problems">
{{#each problems}}
{{> problem}}
{{/each}}
</div>
</template
<template name="problem">
<div class="problem">
<div class="problem-text" id={{_id}}>{{text}}</div>
</div>
</template>
では、私はマッチのIDを取得したいです.problem-textをクリックしました。
イベントを生成した「オブジェクト」について知りたいですか?これはどうすればいいですか?
Template.problem.events = {
'click .problem-text' : function() {
var user_id = Session.get('user_id');
// how to get problem_id of clicked item?
Router.gotoProblem(user_id, this._id);
}
};
Per Meteorのドキュメントでは、「this」オブジェクトに現在のテンプレートデータを受け取ります。 –