administrate-field-jsonb
administrate-field-jsonb copied to clipboard
Duplicated JSONEditor elements with Turbolinks
Hi,
I encountered an issue when using this gem. I'm building a project with Rails 6 and Turbolinks 5.2.1, which I sadly can't share at the moment. When I enter a page with an .administrate-jsoneditor
or .administrate-jsoneditor-viewer
element, the editor would load correctly, but ends up generating multiple copies once I leave and revisit the page.
I suspect that Turbolinks triggers the turbolinks:load
event every time I visit the page, but also keeps the modified DOM between visits, generating multiple copies of the editor after repeated visits.
Sorry for not preparing an example showcasing the problem, but I'm short on time. I hacked together a workaround on this fork, which solves the problem by stopping the creation of a new editor if there's already one present. My solution is not robust at all and the commits were written on a hurry, so it would be better to consider an alternative fix.
Thanks!
Would it be possible to merge this? I am getting bitten by the same bug.