I'm trying to find a working example of the twitter bootstrap typeahead element that will make an ajax call to populate it's dropdown.
I have an existing working jquery autocomplete example which defines the ajax url to and how to process the reply
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
var options = { minChars:3, max:20 };
$("#runnerquery").autocomplete('./index/runnerfilter/format/html',options).result(
function(event, data, formatted)
{
window.location = "./runner/index/id/"+data[1];
}
);
..
What do i need change to convert this to the typeahead example?
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
var options = { source:'/index/runnerfilter/format/html', items:5 };
$("#runnerquery").typeahead(options).result(
function(event, data, formatted)
{
window.location = "./runner/index/id/"+data[1];
}
);
..
I'm going to wait for the 'Add remote sources support for typeahead' issue to be resolved.
?>
UPDATE: I modified my code using this fork
also instead of using $.each I changed to $.map as suggested by Tomislav Markovski
However I am encountering some problems by getting
as you can see on a newer post I am trying to figure out here
hope this update is of any help to you...
I went through this post and everything didnt want to work correctly and eventually pieced the bits together from a few answers so I have a 100% working demo and will paste it here for reference - paste this into a php file and make sure includes are in the right place.
You can use the BS Typeahead fork which supports ajax calls. Then you will be able to write: