Skip to content

Usage with Stimulus

Richard Venneman edited this page Feb 14, 2018 · 1 revision

Create a controller:

import { Controller } from 'stimulus'
import Floatl from 'floatl'

export default class extends Controller {
  connect () {
    this.floatl = new Floatl(this.element)
  }

  disconnect () {
    this.floatl.destroy()
  }
}

Connect the controller with the data-controller attribute on your floatl element:

<div class="floatl" data-controller="floatl">
  <%= f.label :name, class: 'floatl__label' %>
  <%= f.text_field :name, class: 'floatl__input', placeholder: 'Name' %>
</div>

Clone this wiki locally