Wednesday, May 8, 2024
HomeJavaScriptVaried Methods To Get ColdFusion Information Into An Alpine.js Part

Varied Methods To Get ColdFusion Information Into An Alpine.js Part


To date, all of my Alpine.js explorations have been client-side centered. However, my final objective is to see if Alpine.js is an effective companion framework for a ColdFusion-based multi-page software (MPA). As such, I needed to spend a while interested by varied methods through which to get my ColdFusion information into an Alpine.js part.

On this exploration, I am assuming that the requested ColdFusion web page is already fetching the info on the server-side. As such, none of those examples depend on fetch()—or some other API-based workflow—with a purpose to collect information. All of those instance assume that there’s already a request.customers array able to render.

To make that assumption true, I’ve created an ColdFusion software framework part that initializes some pattern information on the prime of every request:

part {

	// Outline the appliance settings.
	this.title = "AlpineJsDataDemo";
	this.sessionManagement = false;
	this.setClientCookies = false;

	// ---
	// LIFE-CYCLE METHODS.
	// ---

	/**
	* I initialize the request.
	*/
	public void operate onRequestStart() {

		request.customers = [
			[ id: 1, name: "Kimmie" ],
			[ id: 2, name: "Ricki" ],
			[ id: 3, name: "Bobbi" ],
			[ id: 4, name: "Sammi" ]
		];

	}

}

Every of the next examples will render this array of customers.

Take a look at the license.



RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments