I have a repeater that is populated with database items. I want the user to be able to select different categories, then click search button. It works fine BUT, the initial database items show briefly BEFORE the filter and sort has completed.
What kind of delay do I need?
site: https://tracesofgold.com
click on songlist, then search songlist…
Here is the code:
import wixData from ‘wix-data’;
import {sendEmail, sendEmailWithRecipient} from ‘backend/email’;
let Filter;
let songReq=‘Test Title’;
$w.onReady( function () {
$w(‘#repeater1’).hide();
$w(“#repeater1”).onItemReady( ($w, itemData, index) => {
$w(“#songTitle”).text = itemData.songTitle;
$w(“#artist”).text = itemData.artist;
$w(“#year”).text = itemData.year;
songReq=itemData.songTitle;
$w(‘#reqMsg’).hide();
} );
});
export function searchButton_click(event) {
let valueGenre = $w(‘#category’).value;
if ( valueGenre === “All By Title”) {
listByTitle();
}
else if ( valueGenre === “All By Artist”) {
listByArtist();
}
else {
Filter = $w(‘#category’).value;
runFilter();
}
}
function runFilter () {
$w(‘#reqMsg’).hide();
$w(‘#dataset1’).setFilter(
wixData.filter()
.contains(‘genre’, $w(‘#category’).value)
)
$w(“#dataset1”).setSort( wixData.sort()
.ascending(“songTitle”)
);
$w(‘#reqMsg’).hide();
$w(‘#repeater1’).show();
$w(‘#reqMsg’).hide();
}
function listByTitle () {
$w(‘#reqMsg’).hide();
Filter = $w(‘#category’).value;
$w(“#dataset1”).setSort( wixData.sort()
.ascending(“songTitle”)
);
$w(‘#reqMsg’).hide();
$w(‘#repeater1’).show();
$w(‘#reqMsg’).hide();
}
function listByArtist () {
$w(‘#reqMsg’).hide();
Filter = $w(‘#category’).value;
$w(“#dataset1”).setSort( wixData.sort()
.ascending(“artist”)
);
$w(‘#repeater1’).show();
$w(‘#reqMsg’).hide();
}
export function requestButton_click(event, $w) {
$w(“#requestButton”).hide();
songReq = $w(“#songTitle”).text;
const subject = Song Request ${$w("#songTitle").text}
;
const body = Thank You
;
const recipient = ‘3868374126@vtext.com’;
//sendEmailWithRecipient(subject, body, recipient)
// .then(response => console.log(response));
sendEmail(subject, body)
.then(response => console.log(response));
$w(“#reqMsg”).show();
}
Also, as you can see the Request Button sends and email, which also works just fine. However, the Hide $w(“#reqMsg”).hide(); DOES NOT HIDE on Live Site. It works perfectly in Preview Mode? I have synced Live DB to Sandbox, cleared cache and cookies and the issue persists! When you click on Search Button and the page displays, you see the “reqMsg” as well as the button. After message has been sent I want to Hide the button and Show the message.
Please help.
Thanks
JD