@foxglovetech/turbo-form

1.3.0 • Public • Published

CircleCI

Turbo Form

This library helps port some functionality from rails-ujs to Turbo.

If you've ever used link_to with remote: true and are thinking about using Turbo as a replacement to UJS - you'll need to do some extra work. However, Turbo give us everything we need to port over this functionality.

Thus, this library.

With this library, you just need to make some slight changes. For example,

Before

<%= link_to "Delete article", @article, remote: true, method: :delete %>

After

<%= link_to "Delete article", @article, data: { controller: "link-method", method: "delete" } %>

The idea is to continue moving forward with Turbo with minimal changes to existing app code.

Installation

yarn add @foxglovetech/turbo-form

Usage

Setup

The first you'll want to do is register the controllers:

import {
  ConfirmController,
  LinkMethodController,
} from "@foxglovetech/turbo-form";

const application = Application.start();
application.register("confirm", ConfirmController);
application.register("link-method", LinkMethodController);

ConfirmController

If you're looking for a confirmation dialog:

<%= button_to "Delete This", some_path(resource_name), data: { controller: "confirm", confirm_message: "Are you sure?" }, method: :delete %>

LinkMethodController

If you need a link to make a request:

<%= link_to "Duplicate", some_path(resource_name), data: { controller: "link-method", method: "post" } %>

Development

Checkout the CONTRIBUTING for info on how to help out with contributions/development.

License

This project is licensed under the MIT License

Readme

Keywords

Package Sidebar

Install

npm i @foxglovetech/turbo-form

Weekly Downloads

16

Version

1.3.0

License

MIT

Unpacked Size

8.81 kB

Total Files

11

Last publish

Collaborators

  • alvincrespo