Skip to content

Undo method #24

Open
Open
@rafaeldev

Description

@rafaeldev

What do you think about adding an undo action?

undo(e: Event): void {
  e.preventDefault()

  // @ts-ignore
  const wrapper: HTMLElement = e.target.closest(this.wrapperSelectorValue)
  wrapper.style.display = ""

  const input: HTMLInputElement = wrapper.querySelector("input[name*='_destroy']")
  input.value = "0"

  const event = new CustomEvent("rails-nested-form:undo", { bubbles: true })
  this.element.dispatchEvent(event)
}

I'm looking for a method like that but I think it's not so simple...

Other important point is about event. Documentation don't tell us about CustomEvent("rails-nested-form:remove", { bubbles: true })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions