Inline Edit Tutorial - v0.4

Documentation for a historical release of Infusion: 1.3
Please view the Infusion Documentation site for the latest documentation.
If you're looking for Fluid Project coordination, design, communication, etc, try the Fluid Project Wiki.

Inline Edit Tutorial - v0.4


Step 0: Download and install the Fluid Infusion library

  1. Download a copy of the Fluid Infusion component library from:

    • http://fluidproject.org/index.php/downloads
      You only really need the "Minified deployment package," but if you want to actually look at the code, you should download the "Source package."

  2. 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 it's name (e.g. fluid-0.4/). The rest of this tutorial will use fluid-0.4 in its examples, but if you downloaded a different version, you'll have to adjust.


Step 1: Prepare your markup

The Changes

That's all - these are the only changes you need to make to your HTML.

* The editable text needs to be wrapped in its own element because this element will be hidden, and replaced with an edit field, when the text is edited. If, in your HTML, you already have an element wrapping your text (for example a <p> or a <div>), you could simply add the text class to that.


Step 2: Write the script

You'll need to create a file, say catalog.js, to contain your initialization script - the script you write to apply the Inline Edit to your album titles.

In this file, write a function that invokes the fluid.inlineEdits() function:

jQuery(document).ready(function () { fluid.inlineEdits("#catalog-table"); });

This function will look inside the element with the "catalog-table" ID (in this case, your <table> element) for anything with the inlineEditable class, and convert everything it finds into an 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.


Step 3: Add the script to your HTML

You'll need to add your initialization script, along with the Fluid library, to you HTML file. In the header of the file, link to the Javascript files with <script> tags:

<script type="text/javascript" src="fluid-0.4/fluid-components/js/Fluid-all.js"></script> <script type="text/javascript" src="catalog.js"></script>

NOTE that the Fluid-all.js file is minified - all of the whitespace has been removed, so it isn't really human-readable. If you're using the source distribution and you want to be able to debug the code, you'll want to include each of the required files individually. This would look like this:

<script type="text/javascript" src="fluid-0.4/fluid-components/js/jquery/jquery-1.2.6.js"></script> <script type="text/javascript" src="fluid-0.4/fluid-components/js/jquery/jquery.keyboard-a11y.js"></script> <script type="text/javascript" src="fluid-0.4/fluid-components/js/jquery/jARIA.js"></script> <script type="text/javascript" src="fluid-0.4/fluid-components/js/fluid/Fluid.js"></script> <script type="text/javascript" src="fluid-0.4/fluid-components/js/fluid/InlineEdit.js"></script> <script type="text/javascript" src="catalog.js"></script>

But all of these individual files are not necessary to make it work - the Fluid-all.js file has everything you need.

So that's it! That's all you need to do to add the Inline Edit functionality to your table cells.

BUT: 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.


Step 4: Apply styles

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.

Important note

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:

If we add a stylesheet with these styles, the table will look like this when the mouse hovers over the album titles: