javascript - Coffee script access to input value -
i new javascript, coffee script, jquery , ui tech in general. trying accomplish simple thing - read value input field far no luck. code pretty simple:
<div class="ui-widget"> <label for="tags">tags: </label> <input id="tags" value="hello"> </div>
from coffee script trying read value follows:
jquery ($) -> $field = $('.ui-widget input') text=$field.val alert #{ text }
but far no luck, contrary via $field.val("bye") works fine.
could please put shed on that?
thx
parameter less function calls require parentheses.
text=$field.val
is translated
var text; text = $field.val;
notice getting function reference val
adding parans:
text=$field.val()
becomes
var text; text = $field.val();
returning result of function rather function itself.
Comments
Post a Comment