Hey everyone, i’m trying to use a date pulled from my CMS in an embedded code block, which would attach a different event listener to my button depending upon if the date has passed or not.
Is this something I would need to use a library like Moment.js for? How would I go about doing this?
This is the general idea of what i’m trying to do:
<script>
var myButton = document.getElementById('myButton');
var date = *date pulled from CMS item*
if (date has passed) {
myButton.addEventListener("click", function() {
Calendly.initPopupWidget({ url: 'https://calendly.com/myorg/event1' });
return false;
})
} else {
myButton.addEventListener("click", function() {
Calendly.initPopupWidget({ url: 'https://calendly.com/myorg/event2' });
return false;
})
}
</script>