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

Flatpickr Not Working in Brython: Initialization Issues #2525

Closed
h4ck4l1 opened this issue Dec 16, 2024 · 2 comments
Closed

Flatpickr Not Working in Brython: Initialization Issues #2525

h4ck4l1 opened this issue Dec 16, 2024 · 2 comments

Comments

@h4ck4l1
Copy link

h4ck4l1 commented Dec 16, 2024

Hello, I am new to brython
Can't use flatpickr, i know dash extensively but i wanted a js alternative with python implementation. How do I use other external libraries like flatpickr?.

from browser import document, html, window #type: ignore


def intialize_datepicker():
    options = {
        "dateFormat":"d-m-Y",
        "allowInput":True,
    }
    print("Flatpickr options: ",options)
    window.console.log("Flatpickr options: ",options)
    window.flatpickr("#register-date", options)

document.bind("DOMContentLoaded",intialize_datepicker)

nothing is getting logged....rest of the internal modules work fine. Any feedback/suggestion is appreciated. Thankyou very much.

@PierreQuentel
Copy link
Contributor

Here is a minimal working example:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Flatpickr Demo</title>

<!-- Brython -->
<script src="https://cdn.jsdelivr.net/npm/brython@3.13.0/brython.min.js">
</script>
<script src="https://cdn.jsdelivr.net/npm/brython@3.13.0/brython_stdlib.js">
</script>

<!-- Flatpickr -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>

</head>

<body>

<input id="test"></input>

<script type="text/python">
from browser import window, document

window.flatpickr(document['test'])
</script>

</body>
</html>

@h4ck4l1
Copy link
Author

h4ck4l1 commented Dec 22, 2024

Thankyou @PierreQuentel for your response. It worked perfectly!.

@h4ck4l1 h4ck4l1 closed this as completed Dec 22, 2024
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