designosis
designosis

Reputation: 5263

How to show ALL category content results in semantic-ui search input?

I want my semantic-ui search input to behave just a bit more like a dropdown, by showing ALL options when clicking the empty field.

Here's a jsfiddle that gets pretty close. It works fine (with fulltext search) after entry ...

enter image description here

... but a way of showing the entire list isn't indicated. I ended up trying something like ...

$('.ui.search').search({
  type: 'category',
  maxResults: 70,
  source: categoryContent,
  fullTextSearch: true,
  searchFields: [
    'title',
    'category'
    ],
  onSelect: function(a){
    // do something
  }
}).on('click', function(){
  if ($(this).val()=='') {
    $('.ui.search').search('show results', function(){
      // this isn't right...
      // how do you show ALL results when clicking empty imput?
    });
  }
});

But that ain't right. Any advice on showing ALL options when the input field is empty?

Upvotes: 2

Views: 1205

Answers (1)

jens
jens

Reputation: 2145

You can set the minCharacters to 0. Try this:

$('.ui.search').search({
  type: 'category',
  maxResults: 70,
  source: categoryContent,
  fullTextSearch: true,
  searchFields: [
    'title',
    'category'
    ],
  onSelect: function(a){
    // do something
  },
  minCharacters: 0
});

Upvotes: 4

Related Questions