Selection tags not working

My selection tags are disabled even though I have them enabled. It’s connected to the dataset and the values are all correct.

import wixData from ‘wix-data’ ;

$w . onReady ( function () {

$w ( "#modFarmTags" ). onChange ( **function**  () { 
    search (); 
}); 

**function**  search () { 

    **let**  filter  =  wixData . filter (); 

    **let**  modFarmIdx  =  $w ( "#modFarmTags" ). selectedIndices ; 
  
    **let**  modFarmVal  =  $w ( "#modFarmTags" ). value ; 
    
    **if**  ( modFarmIdx . length  >  0  ) { 
        filter  =  filter . hasAll ( "modFarm" ,  modFarmVal ) 
        $w ( "#dataset1" ). setFilter ( filter ) 
            . then ( count ) 
    }  **else**  { 
        $w ( "#dataset1" ). setFilter ( filter ) 
            . then ( count ) 
    } 

I have multiple tags but for the sake of this post, I only included one.

What is wrong with the code? Thanks for any help in advance.

You might try adding $w ( “#dataset1” ).onReady(() => {…} inside the page onReady function to make sure your dataset is ready.

It seems like the tags automatically disable when I connect them to the correct data. So they look enabled and when I connect them to the data they automatically go grey and are disabled. Why could that be?

If anyone has this problem: Turns out I had to change the connected dataset to Read-Write instead of just read.