Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

version 0.6.0 has error stopping it working completely #37

Closed
ashenshugarRET opened this issue Jul 8, 2021 · 3 comments
Closed

version 0.6.0 has error stopping it working completely #37

ashenshugarRET opened this issue Jul 8, 2021 · 3 comments

Comments

@ashenshugarRET
Copy link

ashenshugarRET commented Jul 8, 2021

Version 0.6.0 throws the following error when a page load which uses the date picker:

mc-calendar.min.js:1 Uncaught TypeError: Cannot read property 'appendChild' of null
    at oe (mc-calendar.min.js:1)
    at Ce (mc-calendar.min.js:1)
    at Object.create (mc-calendar.min.js:1)
    at HTMLDocument.<anonymous> (test_webpage.php:187)
    at fire (jquery-latest.js:3119)
    at Object.fireWith [as resolveWith] (jquery-latest.js:3231)
    at Function.ready (jquery-latest.js:3443)
    at HTMLDocument.completed (jquery-latest.js:3474)

This occurs whether I reference MCDatepicker with the CDN links or with files stored locally

I've downgraded to v5.1.0 using locally saved files and everything works perfectly.

Here is my code for a typical instance of the datepicker:

            <div id="waffle_area">    
                <div id="waffle_container" style="width: 400px; height: 500px; margin-right: 650px; margin-left: 650px; border:1px solid black; background-color: white; margin: 5px auto" class="right"></div>
                <div class="input__wrapper">
                    <input id="Selected_Date" type="text" class="form-field__input form-field__input--coupled" readonly>
                    <button id="datepicker_btn" class="btn btn--small">
                    <svg class="calendarIcon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"	focusable="false" data-prefix="far" data-icon="calendar-alt" role="img" viewBox="0 0 448 512">
                        <path fill="currentColor" d="M148 288h-40c-6.6 0-12-5.4-12-12v-40c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12zm108-12v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm96 0v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm-96 96v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm-96 0v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm192 0v-40c0-6.6-5.4-12-12-12h-40c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12zm96-260v352c0 26.5-21.5 48-48 48H48c-26.5 0-48-21.5-48-48V112c0-26.5 21.5-48 48-48h48V12c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v52h128V12c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v52h48c26.5 0 48 21.5 48 48zm-48 346V160H48v298c0 3.3 2.7 6 6 6h340c3.3 0 6-2.7 6-6z" />
                    </svg>
                    </button>
                </div>
            <script>
                const datepickerBtn = document.querySelector('#datepicker_btn')
                const dateInput = document.querySelector('#Selected_Date')

                $(function () {
                    const dayOptions = {

                        dateFormat: 'DD MMMM YYYY',
                        bodyType: 'modal',
                        showCalendarDisplay: true,
                        disableWeekends: false,
                        firstWeekday: 1,
                        minDate: new Date("2021-01-10"),
                        maxDate: new Date(Date.now()- (41.5*60*60*1000)),
                        selectedDate: new Date(Date.now()- (41.5*60*60*1000)),
                        closeOndblclick: true,
                        closeOnBlur: true
                    }
                    myDatePickerDate = MCDatepicker.create(dayOptions);
                    document.getElementById("Selected_Date").value = myDatePickerDate.getFormatedDate();
                    myDatePickerDate.onSelect(() => {
                        document.getElementById("Selected_Date").value = myDatePickerDate.getFormatedDate();
                        loadWaffleChart();
                    });

                    datepickerBtn.onclick = () => {
                        myDatePickerDate.open();
                    }

                });
            </script>
            </div>

I hope this helps resolve the error

@mikecoj
Copy link
Owner

mikecoj commented Jul 8, 2021

Hi there, thanks for reporting this, will try to fix this as soon as possible!!

@mikecoj
Copy link
Owner

mikecoj commented Jul 8, 2021

This is fixed in the new version!

@mikecoj mikecoj closed this as completed Jul 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants