[英]Uncaught TypeError: this.source is not a function coffeescript error
[英]Coffeescript gives “Uncaught TypeError: makesSelect is not a function” on passed argument
所以我有这个咖啡脚本
dynamicSelect = (makesSelect) ->
$(document).on 'change', makesSelect, (evt) ->
$.ajax 'update_make_models',
type: 'GET'
dataType: 'script'
data: {
make_id: $(makesSelect 'option:selected').val()
}
error: (jqXHR, textStatus, errorThrown) ->
console.log("AJAX Error: #{textStatus}")
success: (data, textStatus, jqXHR) ->
console.log("Dynamic make select OK!")
dynamicSelect '#diy_attached_vehicles_attributes_0_make'
这给我这个错误
未捕获的TypeError:makesSelect不是函数
是这条线造成的
make_id: $(makesSelect 'option:selected').val()
因此,我应该如何正确传递“ makesSelect”,在匿名函数中,它应该看起来像这样(经过测试并可以工作)
make_id: $('#diy_attached_vehicles_attributes_0_make option:selected').val()
尝试这个:
make_id: $("#{makesSelect} option:selected").val()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.