[英]Rails Javascript Empty string passed to getElementById()
I have a Rails 3.2 app. 我有一个Rails 3.2应用程序。 The following javascript was working fine. 以下javascript工作正常。 Now, it's getting 'Empty string passed to getElementById().'
现在,它正在获得'Empty string passed to getElementById().'
Also getting Use of getPreventDefault() is deprecated. Use defaultPrevented instead.
同时不建议Use of getPreventDefault() is deprecated. Use defaultPrevented instead.
Use of getPreventDefault() is deprecated. Use defaultPrevented instead.
in the console. 在控制台中。
I'm not sure what changed? 我不确定发生了什么变化?
$('#costproject_rebudget_funds').change ->
alert "hey"
checkbox = document.getElementById('costproject_rebudget_funds')
if checkbox.checked
$("#costproject_new").attr('checked', false)
$("#costproject_rebudget").attr('checked', false)
$("#rebudgetamount").show()
else
$("#rebudgetamount").hide()
$("#costproject_rebudget_amount").val('')
I added the alert "hey"
for troubleshooting. 我添加了alert "hey"
以进行故障排除。 It is getting triggered. 它正在被触发。
You use jquery everywhere else except right at the checkbox = document.getElementById('costproject_rebudget_funds') line. 除了在checkbox = document.getElementById('costproject_rebudget_funds')行之外,都可以在其他任何地方使用jquery。 Why not get the element using jquery? 为什么不使用jquery获取元素? checkbox = $('#costproject_rebudget_funds').get(0) perhaps? 复选框= $('#costproject_rebudget_funds')。get(0)? Here is a post possibly talking about some of the issues you are having: How to do this using jQuery - document.getElementById("selectlist").value 这是一篇可能谈论您所遇到的问题的文章: 如何使用jQuery-document.getElementById(“ selectlist”)。value
Particularly note the second answer not the picked one. 特别注意第二个答案而不是选择的答案。
For your deprecation error i'm unsure because you aren't showing the preventDefault code. 对于您的弃用错误,我不确定,因为您没有显示preventDefault代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.