Skip to content

Instantly share code, notes, and snippets.

@spdustin
Created October 31, 2012 21:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spdustin/3989922 to your computer and use it in GitHub Desktop.
Save spdustin/3989922 to your computer and use it in GitHub Desktop.
WIP - jQuery Autocomplete
var acField = $('input[title="Related Task"]');
var listSvc = _spPageContextInfo.webServerRelativeUrl + "/_vti_bin/listdata.svc/";
var listSvcList = "Tasks";
var listSvcFieldQuery = "Title";
var listSvcFieldReturn = "Title";
acField.autocomplete({
source: function(req, res) {
var reqUrl =
listSvc
+ listSvcList
+ "?$filter=startswith("
+ listSvcFieldQuery + ",'"
+ req.term
+ "')";
$.getJSON(reqUrl, function(data) {
res($.map(data.d.results, function(result) {
return result[listSvcFieldReturn];
}));
});
}
});
@joshbooker
Copy link

Note to self: I missed the end of this demo and can't find recording.

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