88052

Typeahead.js does give me suggestions but doesn't select them

Question:

I'm using Bootstrap 3.0 and the latest version of Typeahead.js with the Hogan engine. I managed to get the remote loading of the suggestions to work (finally). Now the next hurdle is when a user clicks on a suggestion, how do I make that the word filled in the input? I thought this was probably done automatically but it doesn't for some reason? Is this just a basic line of JS I'm missing?

The input:

<input class="form-control typeahead playername-search">

This is the JS:

$(document).ready(function() { $('.playername-search').typeahead({ name: "playername-search", remote: 'http://xxxx/%QUERY', template: '

<strong>{{short_name}}</strong> – {{rating}}

', engine: Hogan }); });

One thing I have to mention, everything is inside a modal. Maybe that changes the situation? Thanks in advance!

Answer1:

This happens when typeahead doesn't know what data you want to fill in as a value. Make sure that JSON has either "value" property, or change it with <strong>valueKey</strong>

$('.playername-search').typeahead({ name: "playername-search", valueKey: "short_name", remote: 'http://xxxx/%QUERY', template: '

<strong>{{short_name}}</strong> – {{rating}}

', engine: Hogan });

Recommend

  • Convert a program that uses includes to one using templates
  • Removing duplicate rows by adding column value
  • How to use webview as a browser in android application?
  • Create tar with same name as file but in different folder
  • Propagating model changes to a Parent Controller in Angular
  • Unable to find meaningful logs for ReactNative using Crashlytics
  • Is it bad design to use dynamic_cast in c++
  • Apprequest of Android Facebook sdk 3.0
  • How to implement a callback method within DLL (Delphi / TJVPluginManager + TJvPlugin)
  • How to add a progress ring to the splash screen in Windows 8?
  • Haskell function that outputs all combinations within the input list that add to the input number
  • Error: packet sequence number wrong after upgrading RDS instance
  • Keyboard Extension Crash on Device
  • Lodash cloneDeepWith to omit undefined
  • How to wrap a JMS to WebSphere MQ bridge in a synchronous call using the request-reply pattern?
  • How to get a time and Date Separately?
  • How to put an object in the air?
  • Authorize Attribute Authentication with Postman in Web Api
  • Sample deviceQuery cuda program
  • Android studio import problems. (Apktool)
  • Swift manually rotate view controller
  • Facebook Error (#200) The user hasn't authorized the application to perform this action (PHP)
  • Building JavaFX 2.0 App on Mac, deploying on Windows
  • 'Edit' function for forum posts and such
  • How to use Flask's render_template from an ajax POST form submit
  • How to write seo friendly url's using htaccess?
  • Google Spreadsheet Script to Blink a range of Cells
  • matrix multiplication apache pig
  • Spring Boot fails to start
  • Unity3d lost directional light shadows after generate assetBundle (.unity3d file)
  • Computing the discrete fourier transform of audio data with FFTW
  • Grails - How to implement a foreign key relationship not using an id column?
  • Using Service Component Runtime
  • WPF custom control and direct content support
  • convert json to excel in java
  • Create/delete users from text file using Bash script