1
后一个事件我想集中一个输入框在我的模板后Session.set("quizStarted", true);
流星火Session.set
Template.quiz.startQuiz = function(){
return Session.get("quizStarted");
}
startQuizAnimate = function(){
Session.set("quizStarted", true);
$('.answerBox').focus(); //THIS LINE DOES NOT FOCUS
}
Template.quiz.events({
'click #startQuiz' : function(){
startQuizAnimate();
}
}
<template name="quiz">
<button id="startQuiz">Start!</button>
{{#if startQuiz}}
<form class="answer">
// I want to focus this input text
<input type="text" class="answerBox" name="text" placeholder="Type your answer here" />
</form>
{{/if}}
</div>
</template>
内{{#if startQuiz}}
该块包含我希望把重点放在输入,但我以后叫它Session.set("quizStarted", true);
完成渲染。我怎样才能用Meteor的最佳实践来写这篇文章?
你救了我一个很头疼,这是完美的解决方案! – goda
'Tracker.afterFlush'肯定似乎解决了很多人的问题,不是吗? :) – CaptSaltyJack