繁体   English   中英

未被捕获的TypeError:this.source不是功能coffeescript错误

[英]Uncaught TypeError: this.source is not a function coffeescript error

这里的searchData是一个元素数组。我认为问题出在source但无法弄清楚。
下面是我正在使用的数组。下面的数组是使用get request从json文件中get request

searchData = ["Ruby", "Python", "Java", "C++", "C", "Haskell", "Go", "Scala", "Pascal", "PHP", "Objective-C", "Lisp", "Groovy"]

$.get("/scrolls/search_suggestions.json").done (searchData) ->
    console.log(searchData)
    $("#name").autocomplete ->
        source: searchData
        select: (event,ui) ->
        log if ui.item then 'Selected: '+ui.item.value+' aka '+ ui.item.id else 'Nothing selected, input was ' + @value
        return
      return

我将此页面作为参考: 在这里 。在页面源代码中availableTags名为availableTags的数组。

这段代码对我有用。 在上面,我将$("#name").autocomplete ->为函数。但这是函数调用。我将其更改为$("#name").autocomplete 。这对我有用。

$.get("/scrolls/search_suggestions.json").done (searchData) ->
    console.log(searchData)
    $("#name").autocomplete
        source: searchData
        select: (event,ui) ->
        log if ui.item then 'Selected: '+ui.item.value+' aka '+ ui.item.id else 'Nothing selected, input was ' + @value
 return

希望。有一天它将帮助某人。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM