Blog

No more page refreshing with CBWIRE and Turbo Drive

Grant Copley September 12, 2022

Spread the word

Grant Copley

September 12, 2022

Spread the word


Share your thoughts

tl;dr

Turbo Drive can significantly enhance the user experience of your server-side apps by removing unnecessary page refreshes, and it doesn't take much to implement. Once Turbo Drive is installed, link clinks and form submissions will happen in the background via AJAX. You can use Turbo Drive with or without CBWIRE. If you are using CBWIRE, you can now use a plugin to make CBWIRE and Turbo Drive play together nicely.

CBWIRE and Turbo Drive

One of our core goals with the v2 release of CBWIRE was to get it working with Turbo Drive. Initially, we ran into a bunch of JS errors.

Turbo Drive, formerly Turbolinks, is a JavaScript library that watches for link clicks and form submissions, performs them in the background via AJAX, and updates the page without a full reload. Turbo Drive allows you to build apps that look and feel like single-page applications without completely overhauling your code. Even better, it only takes a couple of lines of code to implement.

Setup

NPM

You can install Turbo by running the following npm command at the root of your project.

npm i @hotwired/turbo

Then you can require or import Turbo.

import * as Turbo from "@hotwired/turbo"

Skypack

There is also a Skypack available which you can add to the <head></head> of your layout.


CBWIRE / Livewire Plugin

For Turbo to work correctly with Livewire ( and therefore CBWIRE ), you will need to include the Turbo plugin below your wireScripts() call in your layout.


Note: You MUST have either the data-turbolinks-eval="false" or data-turbo-eval="false" attributes added to the script tag (having both won't hurt).

Enjoy!

Once Turbo is installed, you should find that clicking links and submitting forms within your app does not require any page refreshes.

Turbo listens for various UI events and fetches the updated content from the server via background XHR requests.

For additional information on how Turbo can be used and configured, please see https://turbo.hotwired.dev/.

Also, you can find the CBWIRE documentation at https://cbwire.ortusbooks.com/.

Build something extraordinary.✌️

Add Your Comment

Recent Entries

BoxLang 1.0.0 Beta 7 Launched

BoxLang 1.0.0 Beta 7 Launched

We are pleased to announce the release of BoxLang 1.0.0-Beta 7! This latest beta version includes improvements and essential bug fixes, but more importantly it certifies the execution of ColdBox HMVC and TestBox.

What is BoxLang?

BoxLang is a modern dynamic JVM language that can be deployed on multiple runtimes: operating system (Windows/Mac/*nix/Embedded), web server, lambda, iOS, android, web assembly, and more. BoxLang combines many features from different progr

Luis Majano
Luis Majano
July 26, 2024
New BoxLang Feature: Java Method References and Higher-Order Functions

New BoxLang Feature: Java Method References and Higher-Order Functions

We’ve added more goodies to our BoxLang Java interop: method references and higher-order functions. CFML has never let you do these things, making Java Interop feel like a second-class citizen. But with BoxLang, we’re elevating Java integration to a new level.

Maria Jose Herrera
Maria Jose Herrera
July 26, 2024
Level Up Your ColdFusion Skills with our Virtual Live Training: ColdBox from Zero to Hero

Level Up Your ColdFusion Skills with our Virtual Live Training: ColdBox from Zero to Hero

Level Up Your ColdFusion Skills with our Virtual Live Training: ColdBox from Zero to Hero

Are you a CFML developer looking to take your skills to the next level? Look no further than the ColdBox from Zero to Hero Virtual Live Training! This intensive two-day course will equip you with the knowledge and expertise to build robust and scalable applications using ColdBox 7, the latest version of the most popular CFML MVC framework.

What You'll Learn:

  • Master the Fun...

Cristobal Escobar
Cristobal Escobar
July 24, 2024