How to hide elements in repeaters if the data is false

Hi im creating a car inventory listing page with options to and filter just like below pic. all the filters dropdown options are connected to dataset as a filter function and it work wells on first load.

currently i have 2 issues.

  1. Not all cars listed is “Deals of the month”, but when it loads, it doesnt show the dark blue banner for the listing that is on sale.

  1. When the page first loads, info such as manufacture year, brand, model and specifications are displayed correctly. but if i go mess with search button or reset button, all the details will be shown as default text.

Would like to ask how can i fix this problem. Below is my code for this page and also item ID and type for the dataset. I personally think that for issue 1, it is the problem with the IF ELSE statement inside FOREACHITEM. and for issue 2, there is something wrong with search and reset function.

import wixData from 'wix-data';

$w.onReady(function () {

	fillincardetails()
});

function fillincardetails() {
	$w("#dataset10").onReady(() => {

		$w("#repeater10").forEachItem(($item, car, ) => {

			let yearbrand = car.yearbuilt + " " + car.brand;
			let model = car.model;
			let carspectext = car.transmission + " · " + car.fuel + " · " + car.type;
			let deals = car.deals
			
			$item('#text18').text = yearbrand;
			$item('#text17').text = model;
			$item('#text64').text = carspectext;

			if (deals === true){
				let dealprice = "RM " + String(car.sellpricerm);
				let beforedealprice = "RM " + String(car.dealpricerm);
				$w('#text63').text = beforedealprice;
				$w('#text62').text = dealprice;

				$w('#text63').show();
				$w('#line2').show();
				$w('#box34').show();
			
			} else {
				let dealprice = "RM " + String(car.sellpricerm);
				$w('#text62').text = dealprice;

				$w('#text63').hide();
				$w('#line2').hide();
				$w('#box34').hide();
			}

		})
	})

}

// lets set what happen when "search" button is clicked
export function searchButton_click(event) {
	search();
}

// search function where it will filter the repeater for values from dropdown
function search() {
	wixData.query("Properties")
		.contains("type",String($w('#dropdown1').value))
		.and(wixData.query("Properties").contains("transmission",String($w('#dropdown2').value)))
		.and(wixData.query("Properties").contains("fuel",String($w('#dropdown3').value)))
		.and(wixData.query("Properties").contains("brand",String($w('#dropdown4').value)))
		.and(wixData.query("Properties").contains("title",String($w('#input4').value)))
		.and(wixData.query("Properties").contains("deals",String($w('#checkbox1').value)))
		
		.find()
		.then(results => {
			$w('#repeater10').data = results.items
		});

}

// lets set what happen when "reset" button is clicked
export function resetButton_click(event) {
	// $w('#propertiesDataset').setFilter(wixData.filter());
	// $w("#propertiesDataset").setSort(wixData.sort());

	$w('#dropdown1').value=undefined;
	$w('#dropdown2').value=undefined;
	$w('#dropdown3').value=undefined;
	$w('#dropdown4').value=undefined;
	$w('#dropdown5').value = undefined;
	$w('#input4').value=undefined;
	$w('#checkbox1').checked=false;

	$w("#dataset10").setSort(wixData.sort().descending("yearbuilt"))

	search();

}

// what happens if the "sort" dropdown changes value
$w("#dropdown5").onChange(() => {

    let dropdownVal = $w("#dropdown5").value;
    //OPTIONS 🎉
    if (dropdownVal === "Price: Low to High") { $w("#dataset10").setSort(wixData.sort().ascending("sellpricerm")) } //Price Low to High
	if (dropdownVal === "Price: High to Low") { $w("#dataset10").setSort(wixData.sort().descending("sellpricerm")) } // Price High to Low
    if (dropdownVal === "Year: Old to New") { $w("#dataset10").setSort(wixData.sort().ascending("yearbuilt")) } // Oldest to Newest
    if (dropdownVal === "Year: New to Old") { $w("#dataset10").setSort(wixData.sort().descending("yearbuilt")) } // Newest to Oldest

});

// what happens if the "brand" dropdown changes value
export function dropdown4_change(event) {
	fillincardetails()
}

// what happens if the "cartype" dropdown changes value
export function dropdown1_change(event) {
	fillincardetails()
}

// what happens if the "transmission" dropdown changes value
export function dropdown2_change(event) {
	fillincardetails()
}

// what happens if the "fuel" dropdown changes value
export function dropdown3_change(event) {
	fillincardetails()
}

// what happens if the "deals of the month" is ticked
export function checkbox1_change(event) {
	fillincardetails()
}
if (deals === true){				
    let dealprice = "RM " + String(car.sellpricerm);				
    let beforedealprice = "RM " + String(car.dealpricerm);				
    $w('#text63').text = beforedealprice;				
    $w('#text62').text = dealprice;				
    $w('#text63').show();				
    $w('#line2').show();				
    $w('#box34').show();						
} else {				
    let dealprice = "RM " + String(car.sellpricerm);				
    $w('#text62').text = dealprice;				
    $w('#text63').hide();				
    $w('#line2').hide();				
    $w('#box34').hide();			
}

Are the marked elements → INSIDE THE REPEATER <— or —> OUTSIDE THE REPEATER?

That’s the question !!!

Yes they are inside the repeater‘s container

But I’m not sure why it still behave like that :persevere:

sorry i didnt make it clear
text62 is the price before discount
text63 is the price after discount
line2 is the line that cross out the before discount price
box34 is the blue container box that shows “Deals of the month”

all these is in the container

Hi an update. I have solve issue 1. Turned out i should have used “$item” instead of “$w”. However, now there’s another issue. The repeater items only display the details correctly until 6-7 items. after that it is showing the default value again. the one highlighted in red is the one showing the default value.

import wixData from ‘wix-data’ ;

$w . onReady ( function () {

fillincardetails () 

});

function fillincardetails ( ) {
$w ( “#dataset10” ). onReady (() => {

    $w ( "#repeater10" ). forEachItem (( $item ,  car , ) => { 

        let  yearbrand  =  car . yearbuilt  +  " "  +  car . brand ; 
        let  model  =  car . model ; 
        let  carspectext  =  car . transmission  +  " · "  +  car . fuel  +  " · "  +  car . type ; 
        let  deals  =  car . deals 
        //console.log("Current-Item: ", yearbrand); 
        //console.log("is it deal?", deals) 
        
        $item ( '#text18' ). text  =  yearbrand ; 
        $item ( '#text17' ). text  =  model ; 
        $item ( '#text64' ). text  =  carspectext ; 
        

        if  ( car . deals  ===  **true** ){ 
            let  dealprice  =  "RM "  +  String ( car . sellpricerm . toLocaleString ()); 
            let  beforedealprice  =  "RM "  +  String ( car . dealpricerm . toLocaleString ()); 
            $item ( '#text63' ). text  =  beforedealprice ; 
            $item ( '#text62' ). text  =  dealprice ; 

            $item ( '#text63' ). show (); 
            $item ( '#line2' ). show (); 
            $item ( '#box34' ). show (); 
        
        }  **else**  { 
            let  dealprice  =  "RM "  +  String ( car . sellpricerm . toLocaleString ()); 
            $item ( '#text62' ). text  =  dealprice ; 

            $item ( '#text63' ). hide (); 
            $item ( '#line2' ). hide (); 
            $item ( '#box34' ). hide (); 
            $item ( '#text63' ). collapse (); 
            $item ( '#line2' ). collapse (); 
            //$item('#box34').collapse(); 
        } 

    }) 
}) 

}