jrief / django-formset

The missing widgets and form manipulation library for Django
https://django-formset.fly.dev/
MIT License
326 stars 35 forks source link

Tom Select already initialized on this element #38

Closed gumish closed 1 year ago

gumish commented 1 year ago

Hello, I've found an error with the Selectize/Tom-select widget. When I move child form with Selectize widget in a sortable FormCollection I get errors: Tom Select already initialized on this element image

I've already tried it here https://django-formset.fly.dev/bootstrap/sortablecontact where I added Selectize widget to label (https://github.com/jrief/django-formset/blob/4b95368f3175d3034ec5e43d72ad55cdec417feb/testapp/forms/contact.py#L81)

    label = fields.ChoiceField(
        label="Label",
        choices=[
            ('home', "Home"),
            ('work', "Work"),
            ('mobile', "Mobile"),
            ('other', "Other"),
        widget=Selectize,
        ],
    )

and it also didn't work without errror.

jrief commented 1 year ago

Thanks for reporting. I'll check this asap.

jrief commented 1 year ago

Could you please retry using this branch: https://github.com/jrief/django-formset/tree/datepicker/client There I check for already initialized modules.

An alternative is to run npm run esbuild.monolith and use <script type="module" src="{% static 'formset/js/django-formset.monolith.js' %}"></script> instead, but this is – as its name suggests – a much bigger JS file.

Remember to build the client as described here: https://django-formset.readthedocs.io/en/latest/development.html

gumish commented 1 year ago

I've just tried both approaches:

jrief commented 1 year ago

I couldn't reproduce this problem locally in my environment. I'll dig into that problem deeper, though.

jrief commented 1 year ago

Please test again with HEAD on main. Should be fixed now. As soon as it works for you, I'll release version 0.13.4

gumish commented 1 year ago

It is much better without any errors in console. But it still looses it's styling. Moved Selectize for example looses its borders (I tried only Bootstrap and Default).

image

jrief commented 1 year ago

@gumish please do not reuse an existing issue to report a different problem. I moved this to #40. If https://github.com/jrief/django-formset/issues/38#issuecomment-1471613320 is fixed, please close.

gumish commented 1 year ago

Yeah, sorry I have almost no experience with GitHub issuing.