<p>For another example of advanced filters, check out the <ahref="{{ site.baseurl }}{% post_url demos/2013-05-02-adaptive %}">compounded filters demo</a>.</p>
<pclass="demo-link-container">Check out the <ahref="{{ site.baseurl }}{% post_url demos/2013-05-02-adaptive %}">compounded filters demo</a>.</p>
<pclass="demo-link-container">Check out the <ahref="#demo">demo</a> at the top of the page, or its <ahref="/js/demos/homepage.js">JavaScript file.</a></p>
<p>The <codeclass="language-javascript">opts</code> parameter can contain two properties. <codeclass="language-javascript">reverse</code>, a boolean which will reverse the array. <codeclass="language-javascript">by</code> is a function that is passed the element wrapped in jQuery. In the case above, we’re returning the value of the data-date-created or data-title attributes.</p>
<p>Calling sort with an empty object will reset the elements to DOM order.</p>
<pclass="demo-link-container">Check out the <ahref="#demo">demo</a>.</p>
<p>The only real important thing here is the <codeclass="language-markup token attr-name">data-groups</code> attribute. It has to be a <ahref="http://jsonlint.com/">valid JSON</a> array of strings. Optionally, it can be a string delimeted by a value you provide. See <code>delimeter</code> in the <ahref="#options">options</a>.</p>
<p>In this example, shuffle is using the fluid grid from the <ahref="http://twitter.github.io/bootstrap/">Twitter Bootstrap</a>. It's also making use of the<ahref="http://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/"><abbrtitle="Block-Element-Modifier">BEM</abbr></a>.</p>
<p>In this example, shuffle is using the fluid grid from the <ahref="http://twitter.github.io/bootstrap/">Twitter Bootstrap v2.3</a>. It's also making use of <ahref="http://csswizardry.com/2013/01/mindbemding-getting-your-head-round-bem-syntax/"><abbrtitle="Block-Element-Modifier">BEM</abbr></a> class naming.</p>
<p>The <code>columnWidth</code> option is used to calculate the column width. You have several options:</p>
<ol>
<li>Use a <strong>sizer</strong> element. This is the easest way to specify column and gutter widths. You can use an element or an element wrapped in jQuery. The column and gutter widths will be measured using this element. The <code>sizer</code> option is an alias for <code>columnWidth</code>. See <ahref="{{ site.baseurl }}{% post_url demos/2013-05-01-basic %}">a demo</a> using a sizer element or <ahref="{{ site.baseurl }}/js/demos/homepage.js">look at the js file</a> for the sizer demo.</li>
<li>Use a <strong>sizer</strong> element. This is the easest way to specify column and gutter widths. You can use an element or an element wrapped in jQuery. The column and gutter widths will be measured using this element. The <code>sizer</code> option is an alias for <code>columnWidth</code>.<spanclass="demo-link-container">See <ahref="{{ site.baseurl }}{% post_url demos/2013-05-01-basic %}">a demo</a> using a sizer element or <ahref="{{ site.baseurl }}/js/demos/homepage.js">look at the js file</a> for the sizer demo.</span></li>
<li>Use a <strong>function</strong>. When a function is used, its first parameter will be the width of the shuffle element. You need to return the column width for shuffle to use (in pixels).</li>
<li>A <strong>number</strong>. This will explicitly set the column width to your number (in pixels).</li>
<li>By default, shuffle will use jQuery's <codeclass="language-javascript">outerWidth(true)</code> to calculate the column width of the first item and use that value.</li>