簡體   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