list.js icon indicating copy to clipboard operation
list.js copied to clipboard

Allow to get the current search text

Open ocarreterom opened this issue 4 years ago • 2 comments

Could be useful to have some property like list.query to get the current search.

Use case:

const list = new List('id')

list.on('update', list => {
  const blankslate = document.querySelector('.blankslate')
  blankslate.textContent = `No results for ${list.query}`
})

ocarreterom avatar Jun 16 '21 15:06 ocarreterom

I just got something like that using the event updated available in the on() method.

There are a method called .update() and a event called .on('updated').

https://listjs.com/api/#on

try

list.on('updated', () => {
    const blankslate = document.querySelector('.blankslate')
    const query = document.querySelector('#searchInput')
   blankslate.textContent = `No results for ${query}`
})

pvictorf avatar Sep 22 '21 14:09 pvictorf

@pvictorf yes, that works but I think could be useful to have a method/attribute to get the current text from the List instance.

ocarreterom avatar Sep 22 '21 16:09 ocarreterom