This page will walk the reader through the steps necessary to use the Lightbox component. For specific information about the Lightbox API, see Lightbox API.
Tutorial: Making images reorderable
The Lightbox is a Fluid component designed to provide the ability to re-order images within a collection. Let's suppose you have some simple markup displaying a small collection of images. To use the Lightbox, your image thumbnails must each be within a
<div> element, and the collection of thumbnails must be contained within an element. A simple example of this could be:
Step 1: Include the Fluid component library
The first step is to include the Fluid component library code in your file. Do this by adding a script tag to the header referencing the
Step 2: Add element IDs
The second step is to add IDs to the elements that the Lightbox needs to know about.
First, add an ID to the element that contains all of the image thumbnails. This ID can be anything unique. For this example, we'll use "image-collection":
Next, we need to add a unique ID to each of the thumbnail
<div> s. This ID must be of a specific form: it must start with the string that was used for the container ID, followed by "lightbox-cell:", a number indicating the index, and finally a ":". This is shown below for our example:
I know this seems a bit complex, but in the real world, these IDs will be generated by the server, and you won't have to write them by hand.
Step 3: Add initialization script
The third step is to actually create the Lighbox by calling the initialization script. This initialization function has the form
The Lightbox initialization function allows you to pass in a number of optional parameters to configure some aspects of the Lightbox, including a 'callback' function. The callback communicates changes in the ordering of images back to the server. In its "out-of-the-box" form, the Lightbox includes a default callback function that uses a form with hidden
<input> elements in the markup to record the indexes of the elements. For our example, we will disable the default callback by specifying an empty function:
Step 4: Define styles
The final step is to create styles so that 'interesting moments' in the reordering of images are easily apparent to the user.
The Lightbox pre-defines a number of class names that will be used for this purpose. It's possible, through the optional configuration, to override these class names, but for this example, we'll just define styles for the default class names.
The first style is the default style to be applied to any image thumbnail.