Hello world!
Welcome to WordPress. This is your first post. Edit or delete it, then start writing!
Welcome to WordPress. This is your first post. Edit or delete it, then start writing!
tag. Mews.Distributor( // Set Configuration ID of your booking engine. { configurationIds: ['29fdb23b-06af-45ac-bc33-afa900973a0b'], }, // Add callback which will enable Submit button and open the Booking Engine Widget upon button click. function (api) { // Listen on submit and when user submits, open booking engine with given dates. const listenOnSubmit = () => { // Find the form in DOM and listen on submit. const form = document.getElementById('date-form'); form.addEventListener('submit', event => { // Don't use the default submit button behavior. We want to handle it ourselves. event.preventDefault(); // Get the dates from the date form. const {start, end} = event.target.elements; const [startYears, startMonths, startDays] = start.value.split('-'); const [endYears, endMonths, endDays] = end.value.split('-'); const startDate = new Date(startYears, startMonths - 1, startDays); const endDate = new Date(endYears, endMonths - 1, endDays); // Use the Booking Engine Widget Javascript API to set the dates in the widget and open it. api.setStartDate(startDate); api.setEndDate(endDate); api.open(); }); }; listenOnSubmit(); // Enable the submit button, because the Booking Engine Widget is ready to be used. const enableSubmit = () => { const submitButton = document.getElementById('dates-submit'); submitButton.value = 'Submit'; submitButton.disabled = false; }; enableSubmit(); } // 4. Note - this guide is written for the Production environment. );