Tôi có một số mã tương tự như sau:Sự kiện Mẫu sao băng, cách nhận đối tượng gây ra sự kiện?
Trong 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>
Trong 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);
}
};
Trong tình huống này, tôi muốn nhận được id của mà phù hợp .problem-text và đã được nhấp.
Tôi muốn biết "đối tượng" đã tạo sự kiện? Làm thế nào để tôi làm điều này?
Mỗi tài liệu Meteor, họ nhận dữ liệu mẫu hiện tại trong đối tượng 'this'. –