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

TestBox Latest Updates and News!

TestBox Latest Updates and News!

We’re thrilled to have launched the new TestBox website and TestBox 6.0! If you haven’t had a chance to explore yet, visit TestBox to discover updated documentation, powerful resources, and features that make testing more efficient than ever.

Maria Jose Herrera
Maria Jose Herrera
November 21, 2024
The Hidden Costs of In-House Database Management

The Hidden Costs of In-House Database Management

The Hidden Costs of In-House Database Management


Opting for in-house database management involves more than just a salary. Here are some often-overlooked costs associated with maintaining your own DBA team.



1. High Salaries and Benefits


Hiring skilled DBAs is expensive. According to industry reports, the average salary of a DBA in the U.S. can range from $85,000 to over $130,000 per year, depending on experience and expertise. When you add ...

Cristobal Escobar
Cristobal Escobar
November 20, 2024
5 Signs It’s Time to Modernize Your ColdFusion / CFML Application

5 Signs It’s Time to Modernize Your ColdFusion / CFML Application

ColdFusion has long been a reliable platform for building web applications, but like any technology, it requires maintenance and modernization over time. Whether you're using Lucee or Adobe ColdFusion, it’s critical to recognize the signs that your application is no longer meeting today’s standards in performance, security, and scalability. Let’s explore five clear indicators that it’s time to modernize your ColdFusion application and how ColdFusion consulting can help breathe new life into y...

Cristobal Escobar
Cristobal Escobar
November 19, 2024