Trying to build a site with search functionality, I experience an interesting site behaviour. To be specific, the search results are different in Wix editor’s preview mode comparing those on the published site. In the code I have written, the search criteria are applied to the data of the third column. Since two entries in this column have the same name (i.e. ‘itemb’), the search result should give two items. This is the case in Wix editor’s preview mode, but when I try it outside of the preview mode on the published site the result only shows one item.
fig1: database
fig2: preview mode with two items
fig3: published site with only one item
As a second issue, I am trying to give users a message saying “No such an entry”, when their entered data is not in the database. Somehow, I have managed to do that, at least in the Wix editor’s preview mode. However, on the published site the message doesn’t show up.
fig4: the message “No such an entry” which only shows up in preview mode
I am wondering why these happen?
My code is as the following
import wixData from 'wix-data';
$w.onReady(function () {
//TODO: write your page related code here...
});
let debounceTimer;
export function input1_keyPress(event, $w) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w('#input1').value, );
}, 200);
}
let lastFilterTitle;
function filter(entry) {
if (lastFilterTitle !== entry) {
$w('#dataset1').setFilter(wixData.filter().eq('entry', entry)).then(() => {
$w("#repeater1").show()
lastFilterTitle = entry;
});
} else {
$w('#dataset1').setFilter(wixData.filter().eq('entry', "No such an entry"))
.then(() => {
$w("#repeater1").show()
lastFilterTitle = entry;
})
}
}