administrate-field-jsonb icon indicating copy to clipboard operation
administrate-field-jsonb copied to clipboard

Duplicated JSONEditor elements with Turbolinks

Open vijuarez opened this issue 3 years ago • 1 comments

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.

image

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!

vijuarez avatar Feb 28 '21 01:02 vijuarez

Would it be possible to merge this? I am getting bitten by the same bug.

ericgross avatar Jan 18 '24 22:01 ericgross