Tutorial - Grid Reorderer 0.5 Migration

This space is an archive space for documentation related to old versions of Fluid Infusion (i.e. versions before 1.3). For documentation related to the latest Infusion, see Infusion Documentation.

Tutorial - Grid Reorderer 0.5 Migration

Initialization

The signature of the call to reorderGrid() has been significantly simplified:

Old

New

fluid.reorderGrid(containerSelector, itemSelector, orderChangedCallback, options);
fluid.reorderGrid(container, options);

The specific changes are as follows:

  • the container parameter can now be

    • a CSS-based selector

    • a single-element jQuery object, or

    • a DOM element

  • the itemSelector and orderChangeCallback are now specified through the options paramter

Item Selector

Instead of passing a selector identifying the orderable items as a parameter to reorderGrid(), selectors are specified using the selectors option.

If you used to have...

Now you would have...

fluid.reorderGrid("#myGrid", ".myItems");
var myOpts = { selectors: { movables: ".myItems" } }; fluid.reorderGrid("#myGrid", myOpts);

If you were using the form of the itemSelector that included movables, selectables, etc., then all of these should be moved into the selectors option:

If you used to have...

Now you would have...

var findItems = { movables: ".orderable", selectables: "div", grabHandle: "div.handle" }; fluid.reorderGrid("#grid2", findItems);
var opts = { selectors: { movables: ".orderable", selectables: "div", grabHandle: "div.handle" } }; fluid.reorderGrid("#grid2", opts);

Order-changed Callback

Instead of passing an order-changed callback function as a parameter to reorderGrid(), the callback is specified using the events option, in particular the afterMove event.

If you used to have...

Now you would have...

var myCallback = function() { ... }; fluid.reorderGrid(myElem, ".movable-item", myCallback);
var myCallback = function() { ... }; var options = { selectors: { movables: ".movable-item" }, events: { afterMove: myCallback } }; fluid.reorderGrid(myElem, options);

Options

Other changes have been made to the format of the options object:

cssClassNames

The cssClassNames option has been renamed to styles:

If you used to have...

Now you would have...

var myClasses = { defaultStyle: "plain", selected: "selected", dragging: "dragging }; var opts = { cssClassName: myClasses }; fluid.reorderGrid(jQuery("body > div:first"), opts);
var myClasses = { defaultStyle: "plain", selected: "selected", dragging: "dragging }; var opts = { styles: myClasses }; fluid.reorderGrid(jQuery("body > div:first"), opts);