I have seen forks of the bootstrap typeahead plugin like this one here:
https://gist.github.com/1866577
However, I am not able to understand how to build the form elements I need for my web application. Basically, I would like my web application to mimic the functionality provided by the following website:
I need 3 autocomplete forms like they have on that website.. but I want to use Twitter Bootstrap as the rest of my web app is in Bootstrap. I need the first autocomplete like for the colleges… This is easy to do with the bootstrap typeahead plugin. I have figured this part out. Now the next to dropdowns with autocomplete is where it gets complex..
I have already learned how to make typeahead dropdowns thanks to this StackOverflow question:
Adding a dropdown button to Twitter bootstrap typeahead component
Now I just need a way to dynamically generate the data source for the drop downs based on which college is selected and then which department is selected. Also, selecting the appropriate course (3rd dropdown) should redirect me to a specific page (eg: site.com/college/coursename.html)
How would I accomplish this with Twitter Bootstrap Typeahead?
Data Example:
Colleges :
- UTEXAS
- UMIAMI
- USC
- STANFORD
Departments:
- 1,2,3 <= STANFORD
- 4,5,6 <= USC
- 7,8,9 <= UMIAMI
- A,B,C <= UTEXAS
Courses:
- a <= 1
- b <= 2
- c <= 3
- d <= 4
- e <= 5
- f <= 6
- g <= 7
- h <= 8
- i <= 9
- j <= A
- k <= B
- l <= C
Warning: I’m a javascript/AJAX noob so please guide me well if javascript/AJAX is involved…
Here is something that should get you started : Live demo (jsfiddle)
This simplistic example shows you how to :
updater.data('typeahead', false)Before any copy/paste, you should know that this uses only the standard typeahead plugin and nothing is done about error handling (input, ajax error, latency user-awareness)