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

Issue on Safari v14.0.3 #124

Open
halhwadi opened this issue Dec 29, 2021 · 0 comments
Open

Issue on Safari v14.0.3 #124

halhwadi opened this issue Dec 29, 2021 · 0 comments

Comments

@halhwadi
Copy link

halhwadi commented Dec 29, 2021

Datepicker works fine on chrome and edge but on Safari it shows error says:
"options.event" must only contains valid Javascript Dates object, even though date are js date objects, please find JS code for your reference :
`<script>

$(document).ready(function (){

$.ajax({
    
    url:"{% url 'calendar' %}",
    success: function (dates) {
    dates = dates['dates'];
    selector = document.getElementById("cal_img");
    
        var year;
        var month;
        var day;
        var year_cal;
        var month_cal;
        var day_cal;
        var events_list = [];
        var date_lookup;

        if (dates.length < 1){
            events_list = [new Date(0000, 00, 00)];
        }
        else {
        for (let i = 0; i < dates.length; i++){
                dates[i] = dates[i].replace(/-/g,",");
                events_list[i] = new Date(dates[i]);  
        }
    }

        const event = datepicker(selector, { position: 'br',
        onSelect: (date) => {
            year_cal = date.dateSelected.getFullYear();
            month_cal = date.dateSelected.getMonth();
            day_cal = date.dateSelected.getDate();
        

            date_lookup = year_cal.toString().concat(",").concat((month_cal + 1).toString().concat(",").concat(day_cal.toString()));

            for (let i = 0; i < dates.length; i++){
                year = new Date(dates[i]).getFullYear();
                month = new Date(dates[i]).getMonth();
                day = new Date(dates[i]).getDate();
                

                if ((year == year_cal) && (month == month_cal) && (day == day_cal)){
                    window.location.href = "{% url 'calendar_loads_list' date_lookup=12345 %}".replace(/12345/,date_lookup.toString());
            }
        }
        
        },
        events:events_list
        
        })
            }
        })
    
    })

</script>`

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

1 participant