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

Cannot expand collapsible element #80

Open
mbaruh opened this issue Sep 14, 2021 · 6 comments
Open

Cannot expand collapsible element #80

mbaruh opened this issue Sep 14, 2021 · 6 comments
Labels
help wanted Extra attention is needed level: 1 - intermediate priority: 1 - high type: bug Something isn't working

Comments

@mbaruh
Copy link

mbaruh commented Sep 14, 2021

I tried adding the following snippet to a django template: https://bulma-collapsible.netlify.app/usage/#collapsible-card
However the element appears collapsed, and pressing the button does not expand it.

Made sure that bulma-collapsible is enabled.

@lemonsaurus lemonsaurus added help wanted Extra attention is needed level: 1 - intermediate priority: 1 - high type: bug Something isn't working labels Sep 27, 2021
@lemonsaurus
Copy link
Owner

This seems like a genuine bug, and I've had two people mention this to me now. If someone wants to help with this, I'd be happy to accept a pull request.

The goal should be that this "just works". django-simple-bulma is supposed to be simple, and that means it should come with batteries included for stuff like this. That probably means putting the right JS in automatically when someone chooses to include this extension.

@Ceres445
Copy link

Adding

<script type="text/javascript" src="/static/extensions/bulma-collapsible/dist/js/bulma-collapsible.min.js"></script>
  <script>
  bulmaCollapsible.attach();
  </script>

to my template made it work after I enabled the extension, the defer on the extension script provided by django_simple_bulma makes my inline script not work, so i had to refer to the same script without the defer to make it work. I don't know how to integrate this into the package and make it work out of the box like @lemonsaurus mentioned, but doing this gets the extension working. Any input would be appreciated

With that said I will try to write an extension script for this to make it work out of the box.

@lemonsaurus
Copy link
Owner

oh, interesting findings. The defer might be the culprit for this whole thing. We could probably conditionally defer scripts if it turns out that this is a bad default...

@lemonsaurus
Copy link
Owner

..might also be related to script load order? hmm.

@Ceres445
Copy link

i dont know enough javascript to fix the defer issue, but we still need the single line script that adds all the collapsible element to make the extension work

@maltherd
Copy link

maltherd commented Dec 2, 2022

There is this defer issue with all extensions.

A simple enough solution right now is to set your code to execute after the DOMContentLoaded event, because it is guaranteed that deferred scripts will have finished executing just at that moment.

In vanilla JS, the fix looks like :

<script>
    window.addEventListener('DOMContentLoaded', function() {
        // use the extensions here
    });
</script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed level: 1 - intermediate priority: 1 - high type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants