Skip to content Skip to sidebar Skip to footer

Twitter Typeahead.js With Scrollto Not Working

I have a datatable (datatables.net) with dynamically generated rows. I have a 'search' box above the datatable. Right now, you can start typing in the box and i have a typeahead gi

Solution 1:

found my solution!

    function addTableSearch(dTable, $container, schedule, stops){
   //while the bus schedule and bus schedule stops exist
    if(schedule !==undefined && schedule.stops !== undefined){
    //getting the future stops
        var notPassed = Fp.filter(schedule.stops, function (stop) { 
                                      return !stop.passed; 
                                  });
            var sequence;
            $container.typeahead({
                source : Fp.pluck(notPassed, 'busStopName'),
                items : 15,
                updater : function(item) {
                    // item is item selected from typeahead
                    var busStopArray = [];
                    $.each(schedule.stops, function(index, value) {
                        busStopArray[index] = value.busStopName
                                + " - " + value.sequence;
                        if (value.busStopName === item) {
                            sequence = value.sequence;
                        }
                    });

                var selector = 'tr[data-sequence="' + sequence + '"]';
                $('#firstSchedule-tab .dataTables_scrollBody').scrollTo(selector);
                $('#secondSchedule-tab .dataTables_scrollBody').scrollTo(selector);


}

addTableSearch(dTable, $('.tblSearch'), schedule.content.get(), schedule.stops);

Post a Comment for "Twitter Typeahead.js With Scrollto Not Working"