Hi All,
I have two repeaters (#repeater1 & #repeater2) on a dynamic page. Both are not connected to a dataset/collection as both are populated via code based on a dataset #marks. I am trying to connect a search bar (#iheadline) and a dropdown (#icategory) for both repeaters, for users to search posts by headline and by category. As the repeaters are not connected to a dataset the standard way, I am struggling with the code.
The code below is what I used for a different repeater that is connected to a dataset the standard way and it works fine:
$w.onReady( function () {
$w( ‘#icategory’ ).value = “” ;
wixData.query( ‘category’ )
.find()
.then(res => {
let options = [{ “value” : ‘’ , ‘label’ : ‘All’ }];
options.push(…res.items.map(category => {
return { ‘value’ : category.category, ‘label’ : category.category };
}));
$w( ‘#icategory’ ).options = options;
})
});
let lastFilterheadline;
let lastFiltercategory;
let debounceTimer;
export function iheadline_keyPress(event, $w) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w( ‘#iheadline’ ).value, lastFiltercategory);
}, 200 );
}
function filter(headline, category) {
if (lastFilterheadline !== headline || lastFiltercategory !== category) {
let newFilter = wixData.filter();
if (headline)
newFilter = newFilter.contains( ‘headline’ , headline);
if (category)
newFilter = newFilter.eq( ‘category’ , category);
$w( ‘#dynamicDataset’ ).setFilter(newFilter);
$w( ‘#marksunmarked’ ).setFilter(newFilter);
lastFilterheadline = headline;
lastFiltercategory = category;
}
}
export function icategory_change(event, $w) {
filter(lastFilterheadline, $w( ‘#icategory’ ).value);
}
export function resetFilter_click(event) {
$w( ‘#icategory’ ).value = “” ;
$w( ‘#icategory’ ).resetValidityIndication();
$w( “#icategory” ).selectedIndex = 0 ;
$w( “#dynamicDataset” ).setFilter(wixData.filter());
}
Question 2
Regarding both repeaters mentioned above, #repeater1 is setup to show posts that have a ticked boolean and #repeater2 has an unticked boolen. The boolen gets an automatic tick after 24hrs. The reason for this is because #repeater2 contains posts that are yet not fully revealed and has a different design (a pop-up is shown onMouseIn over the item). #repeater1 contains visible posts and has a different design. Is there a way that I could have all posts in one repeater, and have the pop up shown only if the boolean is unticked for that particular post?
Thanks in advance!