How to get value of an input text

I have this code:

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) ->
	????

How do I get the value of input text qty? I tried the event variable but its limited in the button. Any ideas?

You can use jQuery like $('#qty').val()

$(event.currentTarget).val()

@chenroth this will just get the value of the button

Ok I found the answer it should be

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

You can see here the documentation about template.find()
Also posted it in stackoverflow and got the answer :slight_smile:

2 Likes

right
sorry, I haven’t noticed that detail