简体   繁体   English

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

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

Here searchData is an array of elements.I think the problem is with source .but cannot figure it out.Help me in finding what is causing error here. 这里的searchData是一个元素数组。我认为问题出在source但无法弄清楚。
Below is the Array i am using.The array below is fetched from a json file using get request . 下面是我正在使用的数组。下面的数组是使用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

I am taking this page as reference: Here .Find the array named availableTags in page source code. 我将此页面作为参考: 在这里 。在页面源代码中availableTags名为availableTags的数组。

This code worked for me. 这段代码对我有用。 In the above i interpreted this $("#name").autocomplete -> as function.But it is function call.I changed it to $("#name").autocomplete .This worked for me. 在上面,我将$("#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

Hope.Someday It will help someone. 希望。有一天它将帮助某人。

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

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