Skip to content

Instantly share code, notes, and snippets.

@shesek
Created February 26, 2012 10:43
Show Gist options
  • Save shesek/1915998 to your computer and use it in GitHub Desktop.
Save shesek/1915998 to your computer and use it in GitHub Desktop.
Custom URL format in jQuery-UI autocomplete source
autocompleteFormat = (url) -> (request, response) -> $.get (url.replace '%s', encodeURIComponent request.term), response, 'json'
# Usage
$('#search').autocomplete
source: autocompleteFormat '/search/%s.json'
var autocompleteFormat = function(url) {
return function(request, response) {
return $.get(url.replace('%s', encodeURIComponent(request.term)), response, 'json');
};
};
# Usage
$('#search').autocomplete({
source: autocompleteFormat('/search/%s.json')
});
@shesek
Copy link
Author

shesek commented Feb 26, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment