This is work in progress. Please do not use as reference.
This documentation refers to the latest trunk version of the Rich Text Inline Edit code. For documentation specific earlier releases, please see Previous Versions of Tutorials
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.
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 four basic steps to adding the Inline Edit to your application:
- Step 1: Add the Markup
- Step 2: Write the script
- Step 3: Add the Fluid library to your HTML
- Step 4: Apply styles
The rest of this tutorial will explain each of these steps in detail.
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 a browser window, this might look something like this:
Unable to render embedded object: File (inline-edit-1.jpeg) not found.
The simplest way to make many pieces of text editable requires you to do three things:
- define the block of text you want to make editable by using a container.
- define how you want the rich inline edit component to look by using a container.
- group the above two containers inside a parent container.
If we want to make the review editable editable, then we could
- wrap entire review text inside a
<span>element and give it the default class
- create a new
<span>element with the default class name
flc-inlineEdit-editContainer. We also define how big we want the rich edit field to be, and add Save and Cancel buttons.
- place the above two
<span>containers inside a
<div>and give it a unique ID.
This might look like the HTML sample to the right.
That's all - these are the only changes you need to make to your HTML.
There are a some scripts you will need to add to your HTML file before the Rich Text Inline Edit will function properly.
<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.
Now you need to initialize the Rich Text Inline Editor.
If using TinyMCE, this can be accomplished by the following code:
If using FCKEditor, 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.
By putting the initialization function inside the
jQuery(document).ready() call, you ensure that all of your markup is ready before you try to initialize the Inline Edit components.
This script can be placed in a
<script> block at the end of your document.
Alternatively, the individual file requirements if using FCKEditor are:
Otherwise, the individual file requirements if using TinyMCE are:
FCKEditor and TinyMCE are not included in the Infusion bundle, but can be downloaded from their respective websites. Refer to
components/inlineEdit/js/InlineEditInegrations.js - the integration file - to see how to technically integrate these editors into your application.
If you look at the file in a browser now, it doesn't look any different than it looked before - there's no way to tell that the album titles are editable. That's what the styles are for.
Like all other components in the Inline Edit family, the Rich Text Inline Edit component can be skinned "out of the box" by including the Fluid Skinning System (FSS) CSS skin files. Just be sure to put the following in you document:
and to attach a class attribute that represents the skin you want to the components container, such as:
The above code would make use of the
fss-theme.mist.css skin file.
If you wish to define your own styles instead, use the following information:
The Inline Edit adds classes to the display text element that can be used to style the element to let users know that the text is editable - that is, to make the functionality 'discoverable.' These classes are applied at various 'interesting moments,' for example when the cursor hovers over the editable text, or when Tab key is used to move focus to the text.
The visual appearance of the styles in the example below are just that: examples. You are free to create whatever styles you like. The important thing to understand is
- what the interesting moments are, and
- what the names of the styles for those moments are
The styles that are applied by the Inline Edit, and the 'interesting moments' they are used for, are:
When: mouse hover and keyboard focus
Why: so that users can know that the text is editable
When: keyboard focus on the text
Why: so that users know that focus is on the text, and that they can press Enter to start editing
If we add a stylesheet with these styles, the page will look like this when the mouse hovers over the album genre:
Unable to render embedded object: File (drop-down-2.png) not found.