bassjobsen/Bootstrap-3-Typeahead

How to allow user input without autocompleting it with suggestion properly?

o28o opened this issue · 0 comments

o28o commented

Hi there. Thank you so much for your your project.

It does exactly what I need and better then other that I've google for.

Test page https://find.dhamma.gift/vass.html

I use it with datatables 1.10 but I have few little problems

  1. How to set delimiter to " " (space). Now it suggests whole sentences but I need just separate words
    screenshot 1

  2. When user types a word e.g. "appa" and hits enter it automatically pastes the whole 1st sentence "Appamādasutta Diligence" from the suggestions. but user don't need the whole sentence but just users input in this case. How to allow user input in this case?
    screenshot 2

Code that I'm using right now

` 'initComplete': function(){
var api = this.api();

     // Populate a dataset for autocomplete functionality
     api.cells('tr', [0, 1, 2, 3, 4, 6]).every(function(){
                    var data = this.data().replace( /(<([^>]+)>)/ig, '');
        if(dataSrc.indexOf(data) === -1){ dataSrc.push(data); }
     });

     // Initialize Typeahead plug-in
     $('.dataTables_filter input[type="search"]', api.table().container())
        .typeahead({
           source: dataSrc,
           afterSelect: function(value){
              api.search(value).draw();
           }
        }
     );`