Skip to content

cableready/alpine_morph

Repository files navigation

Package @cable_ready/alpine_morph

The Alpine.morph() function as a CableReady custom operation meant to be used with cable_ready.

Installation

Install @cable_ready/alpine_morph in your application:

yarn add @cable_ready/alpine_morph

# or

npm install --save @cable_ready/alpine_morph

Usage

Add the Alpine morph operation to CableReady:

// app/javascript/packs/application.js

import CableReady from 'cable_ready'
import AlpineMorph from '@cable_ready/alpine_morph'

CableReady.addOperations(AlpineMorph)

And configure CableReady on the Ruby-side to include the new operation:

# config/initializers/cable_ready.rb

CableReady.configure do |config|
  config.add_operation_name :alpine_morph
end

Known Issues

  • Just works for selector morphs (Alpine doesn't like to morph the whole body element, which is used in page morphs)