Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Section
Column
width60%

This page will walk you through an example of using the Fluid Reorderer's reorderList() function to reorder a list in an HTML file.

This tutorial assumes that:

  • you are already familiar with HTML, Javascript and CSS
  • you are familiar with what the List Reorderer is and does
  • now you just want to know how to add it to your file.

For technical API documentation, see List Reorderer API and Reorderer API.

Tutorial: How to Use the List Reorderer

Scenario

You are organizing a small conference, and there is lots to do. Being the organized person you are, you create a to-do list. You'd like to use the Reorderer to allow the order of items to be changed. This tutorial will show you how to use the Fluid List Reorderer for this.

There are five basic steps to using the List Reorderer in your application:

  • Setup: Download and install the Fluid Infusion library
  • Step 1: Prepare your markup
  • Step 2: Write the script
  • Step 3: Add the script to your HTML
  • Step 4: Apply styles

The rest of this tutorial will explain each of these steps in detail.

Column
Panel
borderColor#321137
bgColor#fff
titleBGColor#aab597
titleStatus
borderStylesolidtitleStatus

This component is in Production status

Panel
borderColor#566b30
bgColor#fff
titleBGColor#D3E3C4borderStylesolid
titleOn This Page
borderStylesolid
Table of Contents
maxLevel5
minLevel2
Panel
borderColor#321137
bgColor#fff
titleBGColor#c1b7c3borderStylesolid
titleSee Also
borderStylesolid
Panel
borderColor#321137
bgColor#fff
titleBGColor#ccccccborderStylesolid
titleStill need help?
borderStylesolid

Join the infusion-users mailing list and ask your questions there.

...

Section
Column

The List Reordeer needs to know about the 'container' of your list. In this case, that would be the <ol> element. The Reorderer accepts a jQuery selector, so you can choose any method that will uniquely identify the <ol> element. We'll attach a unique ID to it:

Code Block
html
html
<ol id="todo-list">
  <li>Select the date</li>
  ...
Column
Panel
borderColor#566b30
bgColor#D3E3C4
titleNote
borderStyleoutsettitleNote

This example uses an ID, but you might, for example, use a CSS class, or the element hierarchy - whatever works, so long as it uniquely identifies the right element.

...

Section
Column
Code Block
html
html
<ol id="todo-list">
  <li>Select the date</li>
  <li class="movable">Create promotional plan
    <ul>
      <li>web site</li>
      <li>print materials</li>
    </ul>
  </li>
  <li class="movable">Book facilities</li>
  <li class="movable">Book block of hotel rooms</li>
  <li class="movable">Develop a conference daily schedule of events</li>
  <li class="movable">Book speakers
    <ul>
      <li>Keynote</li>
      <li>Internal/employee</li>
    </ul>
  </li>
  ...
</ol>
Column
Panel
borderColor#566b30
bgColor#D3E3C4
titleNote
borderStyleoutsettitleNote

As with the ID on the <ol>, we can use any jQuery selector. For example, we could attach a unique ID to each movable <li> with a unique prefix, maybe mylist-movable1, mylist-movable2, etc. Then we could use the jQuery selector [fluid:id^=mylist-movable]

...

Section
Column
Code Block
javascript
javascript
jQuery(document).ready(function () {
    var opts = {
        selectors: {
            movables: ".movable"
        }
    };
    return fluid.reorderList("#todo-list", opts);
});
Column
Panel
borderColor#566b30
bgColor#D3E3C4
titleNote
borderStyleoutsettitleNote

selectors is not the only option that can be used to configure the List Reorderer. For more information, see the List Reorderer API documentation.

...

Panel
borderColor#566b30
bgColor#D3E3C4
titleNote
borderStyleoutsettitleNote

The class names given below are the defaults. It is possible to override these using the styles option, if you desire. For information on how to do this, see the List Reorderer API.

...