【发布时间】:2014-04-21 22:40:31
【问题描述】:
我阅读了很多关于 Blaze 允许 Meteor 0.8 反应式渲染的资源,但我似乎无法为下面的简单问题找到解决方案。
我正在尝试验证我的表单输入。为了简单起见,假设我只想在提交表单时更改我的{{message}}。我在client.js 中采用的方法只是给辅助变量一个新值。这是我过去使用 AngularJS 的方式,但似乎不仅仅是更改 Meteor 中的变量。我该怎么办?
- index.html
<template name="user">
<form>
<input type="text" id="name">
<p>{{message}}</p>
<button class="submit" onclick="return false;">Submit</button>
</form>
</template>
- client.js
Template.user.message = "";
Template.user.events = {
'click .submit' = function(){
Template.user.message = "valid";
}
}
【问题讨论】:
标签: javascript data-binding meteor