[英]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.