Drop down search stopped working

I just published the site and a drop down stopped working. I mangled some code I found, and it was working in every test up until this point.

What should happen: user selects a question, and a different answer pops up. The answers are built with a repeater that loads different elements from another database. You can view it here under the “Surround Simulator”: https://www.surroundins.com/copy-of-how-it-works-debug-x09

The code:

import wixData from "wix-data";

$w.onReady(() => {
    loadContinents();
});

wixData.query("Scenarios dataset")
                .eq("isActive", true)
                .ascending("title")
                .find()
                .then((results) => {
                    $w("#repeater2").data = results.items;
                })
                .catch((err) => {
 let errorMsg = err;
                });

let lastFilterTitle;
let lastFilterContinent;
let debounceTimer;
export function iTitle_keyPress(event, $w) {
 if (debounceTimer) {
        clearTimeout(debounceTimer);
        debounceTimer = undefined;
    }
    debounceTimer = setTimeout(() => {
        filter($w('#iTitle').value, lastFilterContinent);
    }, 500);
}

export function iContinent_change(event, $w) {
    filter(lastFilterTitle, $w('#iContinent').value);
}

function filter(title, continent) {
 if (lastFilterTitle !== title || lastFilterContinent !== continent) {
 let newFilter = wixData.filter();
 if (title)
            newFilter = newFilter.contains('articleTitle', title);
 if (continent)
            newFilter = newFilter.contains('continent', continent);
        $w('#dataset1').setFilter(newFilter);
        lastFilterTitle = title;
        lastFilterContinent = continent;
        }
}

function loadContinents() {
    wixData.query('Continents')
        .find()
        .then(res => {
 let options = [{ "value": '', "label": 'Choose a scenario' }];
            options.push(...res.items.map(continent => {
 return { "value": continent.title, "label": continent.title };
            }));
            $w('#iContinent').options = options;
        });
}

Hey @melindarainsberger :raised_hand_with_fingers_splayed:

First of all, your query is outside the page’s onReady() function, leaving code outside a function laying around like this can break your code.

Apart from that, I see an onKeyPress() event handler but I can’t find where it is, also, what does your filter suppose to filter? Would you explain what’s connected to what?

Thanks @ahmadnasriya !

This is a mangled form of a tutorial I found on Wix’s site. So I can’t be sure what everything is doing.

When a user selects an option from the drop down, an insurance scenario is shown. This means a coverage title, description, button, legal language, and image is loaded up from stuff in a collection. Right now, nothing works, but it did work before we published the site. Here’s a screen shot of the “blank” repeater.

Hey @melindarainsberger :raised_hand_with_fingers_splayed:

You can’t copy and paste a code and expect it to work, you’re using the exact code from the example, you need to adapt it to your needs, for example, you don’t have an input field to use the onKeyPress event handler, and you definitely don’t have fields called " continent " and " title " in your collection. Furthermore, the only event handler you need is onChange() , and you’re not using it.

I do have have fields called Continent and Title—I just changed what went into them.

Is there any way to do what I’m trying to do or am I just going to keep being slammed for not being an expert coder? I came here for help and so far I have only learned that I’m very, very, very bad at this and I don’t know what I’m doing.

It DID work for awhile. So I had no idea that it would break when I made my site live.

What I want to do:

  • Have a drop down list of choices
  • Call up different pieces of text and an image from a repeater.

Is there any answer you can provide that doesn’t require demeaning my abilities? That gives me a real answer on how to solve this?

I need this live in five days. I don’t have the time to learn everything about Corvid. This is why I took one of Wix’s pre-made pages and built from that. And it WORKED. Working from examples seems to be something that Wix/Corvid promotes, but I feel more and more like the answer is to just go away.

I need more help, like exactly the code I should be using. All of it. Written out to be copied and pasted. Because someone that copies and pastes code and asks for help isn’t someone that can read code as precisely as you and instantly write correct code.

Hey @melindarainsberger

I’m very sorry that you feel so, I didn’t mean to criticize or demean your abilities or skills, that was never my intention, and again, I’m very sorry that you felt so.

However, there are some things that you need to consider, and the most important thing is that we expect users to have at least basic understanding of coding in general and JavaScript in particular prior posting, and don’t expect anyone to provide code snippets or full solution - as you demand. Please read the Community Guidelines and adhere to its rules. Also, keep in mind that we, as members ( not Wix employees ) offer our help without requesting anything in return, and I believe that we deserve respect for that no matter how big or little our help is.

If you don’t have the time and the will to learn you can hire a professional developer from the Wix Marketplace .


From what I see from your code, you’re populating the repeater using data binding (query), and then apply the filter on the dataset which is a completely different approach, only one approach must be used at a given time, otherwise, a conflict will rise as a result causing the code to break and produce unexpected results and behavior.

I don’t know what example you’re referring to nor the actual IDs of each element, you should have provided the collection name, fields’ names, elements’ IDs and any other detail that could be useful. Please provide as much details as you can.

Ahmad.

@ahmadnasriya This shouldn’t be that hard. This is a fairly common feature.

The simple question: what code would you write for a drop down that calls up info in a repeater? I’ve followed three different tutorials to the exact line of code and told that somehow the code just knows that I’m a moron and I should give up.

Dropdowns that control results is such a huge feature of shops around the globe. Why is this hard? Besides the answer being “you just don’t know anything.”