Hi everyone, I really need some help urgently.
I have a members page which contains a repeater that is linked to a dataset (#dataset1), which contains a field key with a date and time (#cpdDate).
Site members come to this page to view classes they’ve booked, and have to fill in a register on a separate page to claim professional certification for the classes they have been in.
In the repeater I have a button (#btnCpdRegister) which I want to show/expand within a 48 hour window of the date and time field. I am going a little crazy having scoured these forums and tried nearly every option, but I seemingly cannot get it to work.
I’ve tried the following snippets, none of which I can seem to get to work and I’m not sure what I’m missing?
//filter entire repeater by defined date
$w.onReady(function () {
var startD = new Date(‘12/05/2020’);
var endD = new Date(‘13/05/2020’);
var today = new Date();
if(startD >= today || endD <= today) {
$w('#btnCpdRegister').collapse()
} else {
$w('#btnCpdRegister').expand()
}
});
//filter entire repeater
$w.onReady(function () {
let today = new Date();
$w("#dataset1").setFilter( wixData.filter()
.gt("cpdDate", today)
);
});
//filter entire repeater by defined date
$w.onReady(function () {
var startD = new Date('12/05/2020');
var endD = new Date('13/05/2020');
var today = new Date();
if(startD >= today || endD <= today) {
$w('#btnCpdRegister').collapse()
} else {
$w('#btnCpdRegister').expand()
}
});
//filter entire repeater by Today Date1
$w.onReady(function () {
$w("#dataset1").onReady( () => {
console.log("The dataset is ready");
let d = new Date(); // get today's date
d.setHours(0,0,0,0); // clear out the time
$w("#dataset1").setFilter( wixData.filter()
.lt("cpdDate", d)
.or(
wixData.filter().gt("cpdDate", d)
)
)
.then( () => {
console.log("Dataset is now filtered");
} )
.catch( (err) => {
console.log(err);
} );
});
});