MeteorJS:如何获得input文本的价值

我有这个代码:

product.jade

template(name="product") label(for="qty") Qty: input#qty.form-control(type="text", value="1", name="qty") button.btn.btn-default.addcart Add to Cart 

product.coffee

 Template['product'].events 'click .addcart': (event, template) -> ???? 

如何获得input文本qty的价值? 我尝试了事件variables,但它的button有限。 有任何想法吗?

考虑到你的代码,你可以得到这样的价值:

 'click .addcart': (event, template) -> qty = template.find('#qty').value; 

你可以在这里看到有关template.find()的文档。

但是如果你在<form>上有一个提交事件,你也可以这样做:

 'submit .your-form': (event, template) -> qty = event.target.qty.value //qty = name of the field