I set a data field with Iron router containing 2 fields quizz
and questions
:
Router.route('/profile/quizz/:_id/edit', {
template: 'quizzEdit',
name: 'quizzEdit',
data: function(){
var id = this.params._id;
return{
quizz: function(){
return Quizz.findOne({_id: id});
},
questions: function(){
return Questions.find({});
}
}
}
});
In my template's submit event, I want to get values from my fields, this is what I do:
Template.quizzEdit.events({
"submit .new-question": function(event){
event.preventDefault();
console.log(this.quizz);
event.target.name.value= "";
}
});
The problem is console.log(this.quizz)
, I would like to log my MongoDB object so I can access things like this.quizz._id
, but instead what is log a string containing my router's source code:
function() { // 41
return Quizz.findOne({ _id: id }); // 42
}
Here is an image of my chrome console:
Google console http://img15.hostingpics.net/pics/385623Capture.png
Try calling function:
console.log(this.quizz());