Javascript 咖啡脚本与语境
我试图在触发事件的上下文中获取值Javascript 咖啡脚本与语境,javascript,coffeescript,Javascript,Coffeescript,我试图在触发事件的上下文中获取值$(this),但我得到以下错误: 未捕获的TypeError:无法读取未定义的属性“toLowerCase” 找到解决方案 cants_field_visible.addEventListener "keyup", -> calculate_carbohydrates.call(this, "#{if id == undefined then item_id else id}", "#{if carbohydrates == undefined t
$(this)
,但我得到以下错误:
未捕获的TypeError:无法读取未定义的属性“toLowerCase”
找到解决方案
cants_field_visible.addEventListener "keyup", ->
calculate_carbohydrates.call(this, "#{if id == undefined then item_id else id}", "#{if carbohydrates == undefined then item_carbohydrates else carbohydrates}")
请发布相关的HTML,可能是您误读了错误消息的副本。它没有按照标题说明“无法将属性'val()'设置为null”。上面写着“无法将属性'value'设置为null”。@JordanRunning抱歉,输入错误,它已被编辑。您似乎混合了coffeescript和javascript?
cants_field_visible.addEventListener "keyup", ->
calculate_carbohydrates.call(this, "#{if id == undefined then item_id else id}", "#{if carbohydrates == undefined then item_carbohydrates else carbohydrates}")