Instantly share code, notes, and snippets.

What would you like to do?
define campground engine
var campBH = new Bloodhound({
name: "camp",
datumTokenizer: function (d) {
return Bloodhound.tokenizers.whitespace(;
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
// feature services currently only support query
// if you are using a map server, use find
url: config.featureServerUrl + + "/query?" +
"where=REC_NAME Like '%%QUERY%'" +
"&outFields=REC_NAME,OBJECTID" +
// build the 'datums' that populate the search drop down
// this happens on the callback to the query above
filter: function (data) {
// we only need the name,
// objectid (to retrieve the feature if selected)
// and the source (to later determine which type was selected by the user)
return $.map(data.features, function (feature) {
return {
name: feature.attributes.REC_NAME,
objectId: feature.attributes.OBJECTID,
source: "camp"
// set and remove spinners
ajax: {
beforeSend: function (jqXhr, settings) {
complete: function (jqXHR, status) {
limit: 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment