pascallaliberte / stimulus-turbolinks-select2

A demo on how to fix Turbolinks conflicts with jQuery plugins (like Select2) using Stimulus

Home Page:https://pascallaliberte.github.io/stimulus-turbolinks-select2/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stimulus + Turbolinks and Select2

A demo showing how to make jQuery plugins (like Select2) work with Turbolinks, using Stimulus as the loader/unloader of the plugin.

  • Stimulus (by Basecamp) adds listeners on elements as they appear on the page.
  • Turbolinks (also by Basecamp) loads the next page via pjax.
  • Select2 upgrades select elements with stuff like multi-selection, typeahead, etc.

Watch the video

Used as the demo in this presentation, given at the Ottawa Ruby meetup on January 17, 2018.
Turn Turbolinks Back On: Stimulus Brings the Sprinkles.

Note: the video shows off stimulus@0.9.0 syntax and this demo now runs 1.0, but the difference is only in calling the target elements. this.select is now this.selectTarget, and it's no longer needed to have the get select() getter.

See also:

-- Pascal Laliberté

About

A demo on how to fix Turbolinks conflicts with jQuery plugins (like Select2) using Stimulus

https://pascallaliberte.github.io/stimulus-turbolinks-select2/


Languages

Language:Ruby 43.3%Language:HTML 30.8%Language:CSS 16.2%Language:JavaScript 9.7%