From 9c5fa9b5a98d7330b6d748b2919dc10ecafb0b27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mads=20D=C3=B8rup?= Date: Mon, 13 Mar 2017 13:20:35 +0100 Subject: [PATCH] Add documentation for the transport option This was inspired by: http://stackoverflow.com/questions/33156774/using-http-post-with-typeahead-js-and-bloodhound-js and https://github.com/twitter/typeahead.js/issues/907 --- doc/bloodhound.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/bloodhound.md b/doc/bloodhound.md index ebb4df6d..5b26cec0 100644 --- a/doc/bloodhound.md +++ b/doc/bloodhound.md @@ -272,6 +272,17 @@ When configuring `remote`, the following options are available. you to transform the remote response before the Bloodhound instance operates on it. Defaults to the [identity function]. +* `transport` – A function with the signature `transport(options, onSuccess, onError)` + that allows you to specify a custom transport: + ```javascript + transport: function (options, onSuccess, onError) { + // Modify the options or replace the next line + $.ajax(options) + .done(function(data, textStatus, request) { onSuccess(data); }) + .fail(function(request, textStatus, errorThrown) { onError(errorThrown); }); + } + ``` + [identity function]: http://en.wikipedia.org/wiki/Identity_function