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.
Below is the Array i am using.The array below is fetched from a json file using 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.
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.
$.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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.