laktek / jQuery-Smart-Auto-Complete

AutoComplete plugin with smart defaults and flexibility to customize
http://laktek.com/2011/03/03/introducing-jquery-smart-autocomplete/
248 stars 34 forks source link

Boldface typed text in search results #2

Closed Improvisu closed 13 years ago

Improvisu commented 13 years ago

It would be nice if we could boldface the searched text in the results, so for example, if we had typed "cat" into the query field, the results would be:

<ul>
  <li><em>Cat</em>ch-22</li>
  <li><em>Cat</em>cher in the Rye</li>
  <li>The <em>Cat</em> in the Hat</li>
  <li>Felix the <em>Cat</em></li>
</ul>

To turn this one it could be one simple option:

emphasis: true

Great job with this by the way.

laktek commented 13 years ago

Using the resultFormatter option, you can easily add highlighting to specific portion of a result.

I've added a new example (Example 7) to the demo page, which shows how do it.

I avoided adding an option for this as there was no clear common use case. On many instances, how and what you want to highlight depend on the context.

Improvisu commented 13 years ago

Thanks. That helps. I see what you mean about no clear common use case. I ended up going with the Quicksilver algorithm and with that you can't really use highlighting except for those with a score of 1.