Note that there are some explanatory texts on larger screens.

plurals
  1. POTwitter Typeahead with template always return only 1 row of data
    text
    copied!<p>I am trying to make a similar example as what Twitter show on the examples page, more specifically the one with the template named <a href="http://twitter.github.io/typeahead.js/examples/">Open Source Projects by Twitter</a> and I got something partially working but it only and always show just 1 row of result even though I set it to be 10, I am pulling Yahoo Finance data and the result are JSON and is valid inside Firebug, for example typing letter "a" will make a similar JSON Object of: <code>[Object { symbol="A", name="Agilent Technologies Inc.", exch="NYQ", more...}, Object { symbol="^DJI", name="Dow Jones Industrial Average", exch="DJI", more...}, more objects...]</code></p> <p>My JS file has this typeahead setup</p> <pre><code>$('.symbols .typeahead').typeahead({ //name: 'symbols', //remote: 'yahoo_autocomplete_ajax.php?action=autocjson&amp;symbol=%QUERY', limit: 3, remote: { url: 'yahoo_autocomplete_ajax.php?action=autocjson&amp;symbol=%QUERY', filter: function(parsedResponse) { var dataset = []; dataset = parsedResponse.data; console.log(parsedResponse.data); console.log(dataset); // debug the response here return dataset; } }, //prefetch: 'symbols.json', template: [ '&lt;p class="symbols-exchange"&gt;{{exchDisp}}&lt;/p&gt;', '&lt;p class="symbols-symbol"&gt;{{symbol}}&lt;/p&gt;', '&lt;p class="symbols-name"&gt;{{name}}&lt;/p&gt;' ].join(''), engine: Hogan }); </code></pre> <p>With the console.log of both <code>parsedReponse.data</code> and <code>dataset</code> are both showing a valid array. but at the end it still always show the first result no matter what and the template is working like it should it seems, now in my HTML code I have the examples from Twitter running and it always show all results, but mine just 1..so why? If needed, I can also post my HTML code, I'm only trying to make the example, so the HTML is still simple</p> <p>I also have a <b>2nd problem</b> when it's showing that 1 result even if I click on it to choose it, nothing shows up in my input, though I would like to have the symbol value</p> <p>Here is portion of my HTML code</p> <pre><code>&lt;form&gt; &lt;div class="example symbols"&gt; &lt;h2 class="example-name"&gt;Symbols&lt;/h2&gt; &lt;p class="example-description"&gt;Defines a custom template and template engine for rendering suggestions&lt;/p&gt; &lt;div class="demo"&gt; &lt;input class="typeahead" type="text" placeholder="symbol"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload