list.js
list.js copied to clipboard
Allow to get the current search text
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}`
})
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 yes, that works but I think could be useful to have a method/attribute to get the current text from the List instance.