Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Div
classapi-page

fluid.container(containerSpec, fallible)

Section
Column
width70%

Fetches a single container element and returns it as a jQuery.

Code Block
javascript
javascript
bgColorwhite
borderStylenonejavascript
fluid.container(containerSpec, fallible);

File name: Fluid.js

Parameters

Span
classborderless-table

containerSpec

(String|jQuery|Element) An id string, a single-element jQuery, or a DOM element specifying a unique container.

fallible

(Boolean) (optional) If true, an empty container is to be reported as a valid condition (default: false).

Return Value

Span
classborderless-table

jQuery

a single-element jQuery of specified container

null

if no element is found and fallible is true

Column
width5%

Column

See Also


Notes

  • If fallible is not specified or is false, fluid.container() will throw an error if the specified DOM node is not found.

Examples

Code Block
javascript
javascript
var container = fluid.container("#menu-content");
Code Block
javascript
javascript
var el = document.getElementById("menu-content");
var container = fluid.container(el);

In both of these examples, fluid.container() returns a jQuery object that wraps the DOM node with an id of "menu-content." In both cases, if the node is not found, an error will be thrown.

Code Block
javascript
javascript
var container = fluid.container(".autocomplete-container");
Code Block
javascript
javascript
var auto = jQuery(".autocomplete-container");
var container = fluid.container(auto);

In both of these examples, fluid.container() returns a jQuery object that wraps the DOM node with a class of "autocomplete-container." In both cases, more than one such node is found, an error will be thrown.

Code Block
javascript
javascript
var container = fluid.container("#no-such-id", true);

In this examples, if no node in the DOM has an id of "no-such-id," fluid.container() will not throw an error since the second argument is true: the return value will simply be null.