Hi,

I've been scratching my head over this for a while now - and its driving me up 
the wall. I have the following code:

        $('#typeaheadsearch').attr('autocomplete','off');
    var autocomplete = $('#typeaheadsearch').typeahead( { updater: function 
(item) { 
                $('#typeaheadsearch').val(item); 
                $('#searchForm').submit();
                return item; } } )
        .on('keyup', function(ev){
 
            ev.stopPropagation();
            ev.preventDefault();

            //filter out up/down, tab, enter, and escape keys
            if( $.inArray(ev.keyCode,[40,38,9,13,27]) === -1 ){

                var self = $(this);
                
                //set typeahead source to empty
                self.data('typeahead').source = [];

                                //active used so we aren't triggering duplicate 
keyup events
                if( !self.data('active') && self.val().length > 2){

                    self.data('active', true);
        
                    //Do data request. Insert your own API logic here.
                    $.getJSON("/cgi-bin/links/suggest.cgi",{
                        query: $(this).val()
                    }, function(data) {
        
                        //set this to true when your callback executes
                        self.data('active',true);
                                                
                                                var arr = [];
                                                $.each(data, function(key, val) 
{
                                                        //alert("GOT: " + val);
                                                        arr.push(val);
                                                });

                                                //set your results into the 
typehead's source
                        self.data('typeahead').source = arr;

                        //trigger keyup on the typeahead to make it search
                        self.trigger('keyup');

                        //All done, set to false to prepare for the next remote 
query.
                        self.data('active', false);
                                                
                                        });
                                }
            }
        });     

This invokes my suggest.cgi code, which returns stuff like:

{ "2310": "Espéraza (11260)","11109": "Espérausses (81260)","15822": "Esperce 
(31190)","31663": "Espère (46090)"}

Everything shows up APART from those with a-z chars:

é etc

If I change matcher in bootstrap.js to just be:

  , matcher: function (item) {
      return item; // added
      return ~item.toLowerCase().indexOf(this.query.toLowerCase())
    }

Then it works ok!

Any ideas? Is this a bug?

Cheers

Andy

-- 
You received this message because you are subscribed to the Google Groups 
"twitter-bootstrap" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to