Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
{div:class=api-page}

h1. fluid.container(containerSpec, fallible)
{section}
{column:width=70%}
Fetches a single container element and returns it as a jQuery.
{code:javascript|borderStyle=none|bgColor=white}
fluid.container(containerSpec, fallible);
{code}
*File name:* {{Fluid.js}}

h2. Parameters

{span:class=borderless-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. |
{span}

h2. Return Value
{span:class=borderless-table}
|*jQuery*| a single-element jQuery of specified container |
|*null*| if no element is found _and_ {{fallible}} is true |
{span}

{column}

{column:width=5%}
{column}

{column}
h3. See Also

{column}
{section}
----

h3. Notes

* If {{fallible}} is not specified or is {{false}}, {{fluid.containe()}} will throw an error if the specified DOM node is not found.

h3. Examples
{code:javascript}
var container = fluid.container("#menu-content");
{code}
{code:javascript}
var el = document.getElementById("menu-content");
var container = fluid.container(el);
{code}
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:javascript}
var container = fluid.container(".autocomplete-container");
{code}
{code:javascript}
var auto = jQuery(".autocomplete-container");
var container = fluid.container(auto);
{code}
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:javascript}
var container = fluid.container("#no-such-id", true);
{code}
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}}.

{div}