Skip to content

Instantly share code, notes, and snippets.

@boh1996
Created October 8, 2012 17:32
Show Gist options
  • Save boh1996/3853777 to your computer and use it in GitHub Desktop.
Save boh1996/3853777 to your computer and use it in GitHub Desktop.
Bootstrap Async Example
modal.find('[data-handler="'+ key +'"]').each(function (i, currentElement) {
currentElement = $(currentElement).find(".typeahead");
currentElement.typeahead({
source: function (typeahead,query) {
var url = tableCreator.buildHandlerUrl(handler);
if (typeof handler.query_key != "undefined" && query != null && query != "") {
if (url.indexOf("?") != -1) {
if (url.indexOf("&") != -1) {
url += handler.query_key + "=" + query + "&";
} else {
url += handler.query_key + "=" + query + "&";
}
} else {
url += "?" + handler.query_key + "=" + query;
}
}
if (url != null && url.indexOf("&") != -1) {
url = url.slice(0,url.length-1);
}
url = tableCreator.createAutherizedUrl(url);
if (url != null && url != undefined) {
return $.get(tableCreator.createAutherizedUrl(url),function (data) {
if (objx.get(handler,"response_key") != null) {
data = data[handler.response_key];
return typeahead.process(data);
}
});
}
},
property: handler.property,
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment