Repeater doesn't filter after initial search.

Hi everyone, I have a repeater and I’m filtering products based on a boolean. Everything filters fine on load, but after the user searches and then deletes the other products show up in the repeater. Here’s the code:

$w.onReady(function() {
    $w("#amLogo, #crLogo, #ppLogo").hide();

 const STATE_BOX = $w('#StateBox1');
 /**
    * Changes a state on multi-state box when a button is clicked
    * @param {number} buttonId - the ID of the button.
    * @param {string} state - state of the StateBox to switch to.
    */
 // function changeContent(buttonId, state){
 //   $w(`#button${buttonId}`).onClick( (event) => {
 //     STATE_BOX.changeState(state)
 //   });
 // }
 
 // changeContent(36, 'allBooks2')
 // changeContent(37, 'anthologies');
 // changeContent(39, 'editorsChoice');
 

 const buttons = $w('#group21').children;
 const activeColor = 'rgb(26, 25, 25)';
 const disableColor = 'rgb(118,116,116)';
 const firstBtn = buttons[0];

 
  firstBtn.style.color = activeColor;

  buttons.forEach((btn, index) => {
    btn.style.color = disableColor;
 if(index === 0) {btn.style.color = activeColor}
    btn.onClick((event) => {
      removeActiveState();
      event.target.style.color = activeColor;
 })
 })

 function removeActiveState() {
    buttons.forEach(btn => {
      btn.style.color = disableColor;
 })
 } 
    $w("#repeater1").onItemReady( ($item, itemData, index) => {
 let theItem = itemData.description;
 var shortDescription = theItem.substr(0,300
 );
      $item("#text262").text = shortDescription + "...";
 });
    $w("#anthologiesRepeater").onItemReady( ($item, itemData, index) => {
 let theItem = itemData.description;
 var shortDescription = theItem.substr(0,450);
      $item("#text262").text = shortDescription + "...";
 });
    $w("#editorsChoicerepeater").onItemReady( ($item, itemData, index) => {
 let theItem = itemData.description;
 var shortDescription = theItem.substr(0,450);
      $item("#text262").text = shortDescription + "...";
 });
 
    $w("#repeaterFAQ1").onItemReady(($item) => {
        $item('#Expand1').onClick(() => {
            $item('#AnswerBox1').expand()
            $item('#Expand1').hide()
            $item('#collapse1').show()
 })
        $item('#collapse1').onClick(() => {
            $item('#AnswerBox1').collapse()
            $item('#Expand1').show()
            $item('#collapse1').hide()
 })
 })
})

import wixData from "wix-data";
 
let debouncetimer;
export function input1_keyPress(event) {

 if (debouncetimer) {
    clearTimeout(debouncetimer);
    debouncetimer = undefined;
 }
  debouncetimer = setTimeout(() => {
 let filterValue = $w('#input1').value;
    filter(filterValue);
    console.log(filterValue);
 }, 200);
} 

let lastValue;
function filter(value) {
 if (lastValue !== value) {
    $w('#dataset6').setFilter(wixData.filter()
 .eq('isCaezikScienceFictionAndFantasy', true)
 .contains('bookTitle', value,)
 .or(
        wixData.filter()
 .contains('authorNamesFormatted', value,)
 ))
 .then( () => {
      console.log("Dataset is now filtered");
 } )
 .catch( (err) => {
      console.log(err);
 } )
 }
  lastValue = value;
}

When i take a look onto your code, i recognize that you are not a coding-beginner. Normaly you should be able to resolve your issue by your own with such coding-skills.

Use the —> CONSOLE → to debug your code.

(You have a similar coding-style like me).

I didn’t code all of this. I’ve already reached out to a Professional coder via the “Wix Hire a professional” button and made him a video, which he requested and he hasn’t responded. My client is getting pissed because a repeater isn’t filtering how it’s supposed to filter and I’m getting agitated. Someone please help me solve this issue.

@kyleranta

OK!

  1. Never hire your last PROFESSIONAL again (if he do not offer REVISONS).
  2. My question would be, how you can offer your clients a service, if you are not able to code yourself? → Very risky! But well, this should not be my problem.
  3. I do not know either the whole project-setup nor all it’s interactions. So i think i am not able to help you.

A good coder always first take an overall-overview of a project, before he decides to code some lines. The more details are given —> the better the result will be at the end.

I assume you are not really willing to hire a PROFESSIONAL again, because of your bad experience with a code.

Ok, let’s take a look onto your code…

/**
 * Changes a state on multi-state box when a button is clicked
 * @param {number} buttonId - the ID of the button.
 * @param {string} state - state of the StateBox to switch to.
 */
// function changeContent(buttonId, state){
//   $w(`#button${buttonId}`).onClick( (event) => {
//     STATE_BOX.changeState(state)
//   });
// }

// changeContent(36, 'allBooks2')
// changeContent(37, 'anthologies');
// changeContent(39, 'editorsChoice');


//MSTB1 ---> MultiStateBox-1
import wixData from "wix-data";

// User-Interface ---------------------------------
const STATE_BOX = $w('#MSTB1');
const buttons = $w('#group21').children;
const activeColor = 'rgb(26, 25, 25)';
const disableColor = 'rgb(118,116,116)';
const firstBtn = buttons[0];

const REPEATER1 = "repeater1"
const REPEATER2 = "hologiesRepeater"
const REPEATER3 = "editorsChoicerepeater"
const REPEATER4 = "editorsChoicerepeater"
const DATASET1 = "dataset6"
// User-Interface ---------------------------------

$w.onReady(function() {
    let debouncetimer

    $w("#amLogo, #crLogo, #ppLogo").hide();
    firstBtn.style.color = activeColor;

    buttons.forEach((btn, index) => {
        btn.style.color = disableColor;
        if (index === 0) {
            btn.style.color = activeColor
        }
        btn.onClick((event) => {
            //remove active state
            buttons.forEach(btn => {
                btn.style.color = disableColor;
            })
            event.target.style.color = activeColor;
        });
    });

    $w("input1").onKeyPress(() => {
        if (debouncetimer) {
            clearTimeout(debouncetimer);
            debouncetimer = undefined;
        }
        debouncetimer = setTimeout(() => {
            let filterValue = $w('#input1').value;
            console.log(filterValue);
            FILTER(filterValue);
        }, 200);
    });

    //////////////////////////// [ REPEATER ] ////////////////////////////////////
    $w("#"+REPEATER1).onItemReady(($item, itemData, index) => {
        let theItem = itemData.description;
        var shortDescription = theItem.substr(0, 300);
        $item("#text262").text = shortDescription + "...";
    });


    $w("#"+REPEATER2).onItemReady(($item, itemData, index) => {
        let theItem = itemData.description;
        var shortDescription = theItem.substr(0, 450);
        $item("#text262").text = shortDescription + "...";
    });

    $w("#"+REPEATER3).onItemReady(($item, itemData, index) => {
        let theItem = itemData.description;
        var shortDescription = theItem.substr(0, 450);
        $item("#text262").text = shortDescription + "...";
    });

    $w("#"+REPEATER4).onItemReady(($item) => {
        $item('#Expand1').onClick(() => {
            $item('#AnswerBox1').expand()
            $item('#Expand1').hide()
            $item('#collapse1').show()
        });

        $item('#collapse1').onClick(() => {
            $item('#AnswerBox1').collapse()
            $item('#Expand1').show()
            $item('#collapse1').hide()
        });
    });
})

function FILTER(value) {let lastValue;
    if (lastValue !== value) {
        $w('#'+DATASET1).setFilter(wixData.filter()
        .eq('isCaezikScienceFictionAndFantasy', true)
        .contains('bookTitle', value, )
        .or(wixData.filter().contains('authorNamesFormatted', value, )))
        .then((res) => {
            console.log("Dataset is now filtered");
            console.log(res);
        })
        .catch((err)=> {console.log(err);});
    }
    lastValue = value;
}

This should already look a little bit better.

  1. Import goes always onto TOP of the page-code!

  2. Defining User-Interfaces is ALWAYS BETTER !
    What the hell is a → “user-interface” ? Well i don’t know if this word exists in the coding-universe (just an invention of myself, but surely existing but called with another name). It is where the prgrammer defines an CODE-AREA for, (either himself for better working and adding new modules to his own project, or defining an CUSTOMER-INTERFACE to let the customer work an easier way with the coded project.

  3. Using a better structure.

  4. Surely here we can modify and improve more…

At least, after investigating the code and it’s structre, i must say →

IT COULD NOT BE A PRO, WHO MANAGED THIS ONE ! ! !
Next time you should choose carefully your next PROFESSIONAL :grin:

Ok, back to you problem…
As i already mentioned, the programmer should have more inputs to help you out.

BTW: Also did not find anything about —> const STATE_BOX = $w ( ‘#MSTB1’ ); in your CODE.