JQuery UI Autocomplete from Coffeescript -


i'm trying use jquery ui's autocomplete , have following code

$( '#searchbar' ).autocomplete source: ( request, response ) -> $.ajax({ url: "$$ apiurl pt.casemanagement $$/case/search" }) success: ( data ) ->             response([               { label: "example", value: 'testing'}             ]) 

i'm waiting success , injecting random label , value response testing purposes. bar sending , getting 200. can see values server, whatever reason doesnt seem being populated in searchbar. should able (as far understand) type 'e' , see 'example' auto suggested, right?

does syntax seem wrong?

your syntax indeed wrong. main issue indentation. blocks defined indentation in coffeescript, wanted this:

$( '#searchbar' ).autocomplete   source: ( request, response ) ->     $.ajax({       url: "$$ apiurl pt.casemanagement $$/case/search"       success: ( data ) ->         response([           { label: "example", value: 'testing'}         ])     }) 

also, closing options object $.ajax call before finishing literal object definition. didn't change other whitespace or syntax make clear indentation implies.

in coffeescript, can omit parens function calls arguments , braces around objects (unless it's ambiguous or need bypass default precedence rules), code cleaner this:

$('#searchbar').autocomplete   source: (request, response) ->     $.ajax       url: "$$ apiurl pt.casemanagement $$/case/search"       success: (data) ->         response [           label: 'example'           value: 'testing'         ] 

if need further details why , how works, let me know , can go line-by-line on it.


sidenote: you're not using request parameter autocomplete values server. means won't expected results server, since you're not sending search term.


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

how to receive file in java(servlet/jsp) -