var substringMatcher = function(strs) { return function findMatches(q, cb) { var matches, substringRegex; // an array that will be populated with substring matches matches = []; // regex used to determine if a string contains the substring `q` substrRegex = new RegExp(q, 'i'); // iterate through the pool of strings and for any string that // contains the substring `q`, add it to the `matches` array $.each(strs, function(i, str) { if (substrRegex.test(str)) { matches.push(str); } }); cb(matches); }; }; var products = ['1 - HDB 3000mm Galaxy Woollen Card Year 2005, 160 good ends (Ref. 12169)','16092A Barmag DD2000GT Twisting 24 spindles Year 2018','16092B Barmag STC DD2000GT Twisting 24 spindles Year 2019','16092C 8 off Twistechnology TWISTUP 2 spindle each Year 2017','16092D Barmag STC MaryTex Texturiser 24 spindles Year 2023','16092E Barmag Oerlikon Texturising WRM 8 spindles Year 2017','2 - HDB Woollen Spinning Frames Year 2002 160 spindles (Ref. 12169)','2 HDB Woollen Spinning Frames Year 1996 (Ref. 12179)','CA6 Worsted Card Double Doffer 2500mm Year 1994 (13065)','Carbon Fibre Yarn Spinning and Coating Line Year 2013 (Ref. 12178)','Cliffe Tow Cutter (Ref. 12174)','Cushion Fibre Filling Production Line (Ref. 12185)','Dataweave 90cm Sample Loom with Bonas Electronic Jacquard (Ref. 16093)','Dornier P2 Year 2022 for Carbon Fibre or Glass Fibre Weaving','Fabotex WF1 Fringing Machine Year 2015','Fully Automated Fibre Filling System (Ref. 12186)','Gaudino Ring Spinning FPK03 (12178)','Gaudino Ring Twisting BRH (12178)','Haigh Chadwick Fearnought 1800mm (Ref. 12169A)','Haigh-Chadwick Hopper Feeder (Ref.12157)','HDB Double Doffer Nonwoven Card 2500mm (Ref. 13058)','KARL MAYER ROB Warping Machine Year 2003 (Ref. 16082)','NSC Scglumberger FM8 Horizontal Rubbing Frame Year 1997 14082D','NSC Schlumberger FM8N Horizontal rubbing frame 20 spindles Year 1996 (Ref. 14082B)','OMMI Step Cleaner - Model OM83 Year 2005 (Ref. 13072)','Pillow Fibre Filling Line (Ref. 12185)','Q-SUN Xenon Test Chamber, Model B02 (Ref. 12189)','Seydel NSC Schlumberger Converter FB20 (12178)','Staubli Unival 512 Electronic Jacquard Year 2010 (16081)','Tatham BLOW FILLING PRODUCTION LINE FOR PILLOW / CUSHIONS','Tatham Laboratory( Research/Sample) Non Woven Card','Texkimp Flanged bobbin yarn creel with tensioners brake (12178)','Thibeau CA6 Non Woven Card Double Doffer 2500mm Year 1994 (13065)','Thibeau CA6 Worsed Card Double Doffer 1500mm (13065)','TVE ESCALE High Efficiency Washing System - Open width scour machine (Ref. 12184)' ]; var productsIDs = [ ]; $('#our-products .typeahead').typeahead({ hint: true, highlight: true, minLength: 1 }, { name: 'products', limit: 40, source: substringMatcher(products) });