Home page search to other page and filter.

Hello to everyone.

I have this filter box and dropdown box on my category dynamic page and its absolutely working 100% together with my search count and pagination.

I find Ms. Gomez search tutorial and i like how it was presented, its really working but there are some issues with my count search and pagination if i used her tutorial.
I used the search code on her tutorial with the codes below. It push the value to my category page and what i typed is in the filter box as well.

$w.onReady( function () {
var sameWord = local.getItem(“searchWord”);
$w(“#iTitle”).value = sameWord;
$w(“#iTitle”).placeholder = sameWord;
$w(“#dataset1”).onReady( function () {
});
});

I just thought that whatever written on my filter box will do its function to filter. Unfortunately, it requires me to press the “enter” on my keyboard to do its function. Is there a way to do its automatically and not need to press the enter?

Here’s the complete code i am using

$w.onReady( function () {
var sameWord = local.getItem(“searchWord”);
$w(“#iTitle”).value = sameWord;
$w(“#iTitle”).placeholder = sameWord;
$w(“#dataset1”).onReady( function () {
});
});

$w.onReady(() => {
wixData.query(‘Category’)
.find()
.then(res => {
let options = [{“value”: ‘’, ‘label’: ‘All Tours’}];
options.push(…res.items.map(category => {
return {‘value’: category.title, ‘label’: category.title}
}));
$w(‘#iTours’).options = options;
})
});

let count;
let lastFilterTitle;
let lastFilterCategory;

let debounceTimer;
export function iTitle_keyPress(event, $w) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w(‘#iTitle’).value, lastFilterCategory);
}, 0);
}

function filter(title, category) {
if (lastFilterTitle !== title || lastFilterCategory !== category) {
let newFilter = wixData.filter();
if (title)
newFilter = newFilter.contains(‘title’, title);
if (category)
newFilter = newFilter.eq(‘category’, category);
$w(‘#dataset1’).setFilter(newFilter).then(() => {
count = $w(“#dataset1”).getTotalCount();
$w(‘#result’).text = count.toString();
lastFilterTitle = title;
lastFilterCategory = category;
});
}
}

export function iTours_change(event, $w) {
filter(lastFilterTitle, $w(‘#iTours’).value); //Add your code for this event here:
}

Hope anyone can help me so i can finalize our website.

Thank you

Hi,
I’m afraid that we cannot debug your code for you. However, be aware that it is not recommended to use multiple onReady function, since it creates a race condition (meaning, you won’t know which one is "fired first). This is what probably cause the issue.

Good luck,
Tal.

Hi Tal.

Thank you for the reply. Appreciated!
I figured out the code and happy it’s working just yesterday night.