I’m having some trouble trying to code a dropdown search bar. I’m not familiar with codding, I’m codding following tutorials and Corvid’s Doc so I don’t know what’s wrong with code. It’s 4 dropdown with Property, Property Type, City, Bedroom and a Search button. Can you guys help me figure out what’s wrong with code?
import wixData from 'wix-data';
export function button3_click(event, $w) {
$w("#dataset1").setFilter(wixData.filter()
.contains("tipoImovel", $w('#dropdown1').value)
.contains("voceQuer", $w('#dropdown2').value)
.contains("cidadeDaCasa", $w('#dropdown3').value)
.contains("quartos", $w('#dropdown4').value)
.then((results) => {
console.log("Dataset is now filtered");
$w("#repeater1").data = results.items
}).catch((err) => {
console.log(err);
});
$w("#repeater1").expand();
}
@jonatandor35 I really don’t know, I followed this tutorial (https://www.youtube.com/watch?v=QhMKnm1f6EU) but the dropdown don’t work, I think it’s missing filters or something like that but I have no clue how to do this! See the link of my website I sent below.
@estefanomarques I really can’t help you without more details and without seeing the full page code (I don’t know if you posted all of it).
However, I can see an error on your site when the page loads.
This type of error can be caused by wrong collection permissions.
So check the permissions.
@jonatandor35 That’s the full code, I’m only using that single code for dropdown searchbox. I’ll check the collection permissions then and probably keeping searching how to fix that. Thanks dude!
@jonatandor35 Hi J.D. Thank you so much for trying to help me to code the dropdown filter, I figure it out using only Wix settings with no codes, except for the Reset button.
But now I have a different question. I’ve added a code to fadeIn and fadeOut in a button when I scroll the page but when I use the dropdown filter, it still showing the Find More button, even if it doesn’t have new content to load. There’s a code I can add to remove or fadeOut the “Find More” button after loading all the content? The number of items that I set to database is 12. You can test it choosing “Casa” in “Tipo do Imóvel”, “Comprar” in “Você Quer?” and “Ribeirão Preto” in “Cidade”. There’s only 16 repeaters for that search but even after loading all content, it still showing the “Descubra Mais”(Find More) button. And after I click to Reset the search, the Find More function still active, it don’t back to 12, the number of items I setted in database. How can I fix this?
That’s all the coding I’m using:
import wixData from 'wix-data';
export function reset_click(event, $w) {
$w("#dropdown1").value = undefined;
$w("#dropdown2").value = undefined;
$w("#dropdown3").value = undefined;
$w("#dataset1").setFilter(wixData.filter());
}
export function descubra_click(event) {
$w("#dataset1").loadMore();
}
export function anchor1_viewportEnter(event) {
$w("#descubra").show("FadeIn");
}
export function anchor1_viewportLeave(event) {
$w("#descubra").hide("FadeOut");
}
@estefanomarques maybe try to check if it hasNext after you run a filter.
$w("#dataset1").setFilter(wixData.filter())//do it to any other of your filters as well
.then(() => {
$w("#dataset1").hasNext() ? $w("#button1").show() : $w("#button1").hide();
})
As you can see, everytime you click in “Descubra Mais” (Load More) button and click in “Limpar Seleção” (Reset Dropdown) button, the repeater keeps showing all the contents, it doesn’t reset with dropdown.