This tutorial assumes that:
- you are familiar with what the Inline Edit is and does
- now you just want to know how to add it to your file.
Tutorial: How to Use the Inline Edit
You've created a database to keep track of your vast collection of CDs, and you're working on a web interface for it. When viewing the details of a CD, you would like to very easily add a personal review. Prone to rambling, you know you will want to add some basic styling so the text is easier to read. This tutorial will show you how to use the Fluid Rich Text Inline Edit for this.
There are three basic steps to adding the Inline Edit to your application:
- Setup: Download and install the Fluid Infusion library
- Step 1: Prepare your Markup
- Step 2: Write the script
- Step 3: Add the required libraries to your HTML
The rest of this tutorial will explain each of these steps in detail.
Setup: Download and install the Fluid Infusion library
- Download a copy of the Fluid Infusion component library from:
You only really need the "Minified deployment package," but if you want to actually look at the code, you should download the "Source package."
- Unpack the zip file you just downloaded, and place the resulting folder somewhere convenient for your development purposes.
The folder will have the release number in its name (e.g. infusion-1.4/). The rest of this tutorial will use infusion-1.4 in its examples, but if you downloaded a different version, you'll have to adjust.
Step 1: Prepare your markup
Let's assume that you're working with some HTML that displays the information about a CD in your collection - something simple like this:
In order to apply the Rich Text editor to your markup, you need to tell it three things:
- which element is the block of text you want to make editable by identifying a container,
- how you want the rich inline edit component to look by using a another container, and
- group the above two containers inside a parent container.
If we want to make the review text element editable, then we could
- wrap entire review text inside a
<div>element and give it the default class
- create a new
<div>element with the default class name
flc-inlineEdit-editContainerfor the editor.
- place the above two
<div>containers inside a
<div>and give it a unique ID.
We can also define how big we want the rich edit field to be, and add Save and Cancel buttons.
This might look like the HTML sample to the right.
Step 2: Write the script
There are some scripts you will need to add to your HTML file before the Rich Text Inline Edit will function properly.
Define Button Behaviour
<button> elements by themselves will not do anything special unless we specify some behaviour. This can be done by adding the following script:
This will make the
Cancel buttons perform what we'd expect.
Initialize the Rich Text Inline Editor
Now you need to initialize the Rich Text Inline Editor.
If using TinyMCE, this can be accomplished by the following code:
Note: We specify an optional width for the TinyMCE editor so that it fits the width of the container more closely.
If using CKEditor, this can be accomplished by the following code:
This function (regardless of the editor being used) will look inside the element with the "cd-review" ID (in this case, your
<div> element) for anything with the
flc-inlineEdit-editContainer class, and convert it into an Rich Text Inline Edit field.
Note: The FCKEditor integration is deprecated for v1.2. Please use the CKEditor integration instead.
Putting it All Together
Combining all of the above scripts together, it will look like this:
By putting these functions inside the
jQuery(document).ready() call, you ensure that all of your markup is ready before you try to initialize the Rich Text Inline Edit components. This script can also be placed in a
<script> block at the end of your document.
Step 3: Add the Fluid library to your HTML
Alternatively, the individual file requirements if using CKEditor are:
Otherwise, the individual file requirements if using TinyMCE are: