Skip to content

preventDefault issue #632

Description

@hksk

Im using adminsitrate with nestedHasmany gem, and I got some errores for cocoon + turbo

currently I report a issue here:
nickcharlton/administrate-field-nested_has_many#81

when a Turbo page is loaded , the event is added to "Add" button , so If I navigate 10 times with turbo, when i click the add button, then 10 childs forms are created

I do a bad patch to fix that

replacing the add field event to remove the listener

  document.querySelectorAll('.add_fields').forEach(function(element) {
    // Correctly remove the event listener
    element.removeEventListener('click', addFieldListener);
    // Add the event listener again
    element.addEventListener('click', addFieldListener);
  });

  function addFieldListener(e) { ...

and works.. someone knows if this is a normal issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions