I'm filtering search results based on title and description fields in the database. The filter updates from an input field. The problem is that when a user types cmd+backspace and clears the input, it doesn't update the search term. Whatever the results of the last search term stay on the page. For example, if I enter an invalid search term, like "acbrgr", nothing is returned. If I cmd+backspace, still no results appear. If I backspace one character at a time to clear the field, then it restores the original data normally. If I enter a search term that is valid and displays a subset of results, cmd+backspace still shows that subset. I'd expect it to properly display all data.
import wixData from 'wix-data'; $w.onReady(function () { $w('#input15').onInput((event) => { $w('#dataset1') .setFilter( wixData.filter().contains('title', event.target.value) .or(wixData.filter().contains('description', event.target.value)) ) }) });
Is this a bug with filtering? I've console logged the event.target.value on cmd+backspace, and it is ''. Same value when backspacing one character a time.
Hello Info,
not sure if my statement is right, but your issue could caused by the missing "dataset.onReady"-command.
You should alwasy use it when working with datasets. The dataset has first to be loaded /updated kompletely, bevor access it (do a query).
Perhaps this will help...
$w.onReady( () => { $w("#dataset1").onReady( () => { // . . . and then your CODE here . . . } ); } );