methods.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Methods &middot; Isotope Docs</title>
  6. <!--[if lt IE 9]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
  7. <link rel="stylesheet" href="../css/style.css" />
  8. <!-- scripts at bottom of page -->
  9. </head>
  10. <body class="docs ">
  11. <nav id="site-nav">
  12. <h1><a href="../index.html">Isotope</a></h1>
  13. <h2>Docs</h2>
  14. <ul>
  15. <li><a href="../docs/introduction.html">Introduction</a>
  16. <li><a href="../docs/options.html">Options</a>
  17. <li class="current"><a href="#content">Methods</a>
  18. <ul class="toc">
  19. <li><a href="#additems">addItems</a></li>
  20. <li><a href="#appended">appended</a></li>
  21. <li><a href="#destroy">destroy</a></li>
  22. <li><a href="#insert">insert</a></li>
  23. <li><a href="#layout">layout</a></li>
  24. <li><a href="#option">option</a></li>
  25. <li><a href="#relayout">reLayout</a></li>
  26. <li><a href="#reloaditems">reloadItems</a></li>
  27. <li><a href="#remove">remove</a></li>
  28. <li><a href="#shuffle">shuffle</a></li>
  29. <li><a href="#updatesortdata">updateSortData</a></li>
  30. </ul>
  31. </li>
  32. <li><a href="../docs/layout-modes.html">Layout modes</a>
  33. <li><a href="../docs/filtering.html">Filtering</a>
  34. <li><a href="../docs/sorting.html">Sorting</a>
  35. <li><a href="../docs/animating.html">Animating</a>
  36. <li><a href="../docs/adding-items.html">Adding items</a>
  37. <li><a href="../docs/extending-isotope.html">Extending Isotope</a>
  38. <li><a href="../docs/hash-history-jquery-bbq.html">Hash history with jQuery BBQ</a>
  39. <li><a href="../docs/help.html">Help</a>
  40. <li><a href="../docs/license.html">License</a>
  41. </ul>
  42. <h2>Demos</h2>
  43. <ul>
  44. <li><a href="../demos/basic.html">Basic</a>
  45. <li><a href="../demos/elements-complete.html">Elements Complete</a>
  46. <li><a href="../demos/elements-partial.html">Elements Partial</a>
  47. <li><a href="../demos/layout-modes.html">Layout modes</a>
  48. <li><a href="../demos/filtering.html">Filtering</a>
  49. <li><a href="../demos/sorting.html">Sorting</a>
  50. <li><a href="../demos/relayout.html">reLayout</a>
  51. <li><a href="../demos/adding-items.html">Adding items</a>
  52. <li><a href="../demos/infinite-scroll.html">Infinite Scroll</a>
  53. <li><a href="../demos/images.html">Images</a>
  54. <li><a href="../demos/combination-filters.html">Combination filters</a>
  55. <li><a href="../demos/hash-history.html">Hash history</a>
  56. <li><a href="../demos/fluid-responsive.html">Fluid / responsive</a>
  57. </ul>
  58. <h2>Custom layout modes</h2>
  59. <ul>
  60. <li><a href="../custom-layout-modes/centered-masonry.html">Centered Masonry</a>
  61. <li><a href="../custom-layout-modes/category-rows.html">Category rows</a>
  62. <li><a href="../custom-layout-modes/masonry-corner-stamp.html">Masonry corner stamp</a>
  63. <li><a href="../custom-layout-modes/masonry-gutters.html">Masonry gutters</a>
  64. <li><a href="../custom-layout-modes/spine-align.html">Spine align</a>
  65. </ul>
  66. <h2><a href="../tests/index.html">Tests</a></h2>
  67. </nav> <!-- #site-nav -->
  68. <section id="content">
  69. <h1>Methods</h1>
  70. <p>Isotope offers several methods to extend functionality. Isotope&#8217;s methods follow the jQuery UI pattern.</p>
  71. <div class='highlight'><pre><code class='javascript'><span class='nx'>$</span><span class='p'>(</span><span class='s1'>&#39;#container&#39;</span><span class='p'>).</span><span class='nx'>isotope</span><span class='p'>(</span> <span class='s1'>&#39;methodName&#39;</span><span class='p'>,</span> <span class='p'>[</span><span class='nx'>optionalParameters</span><span class='p'>]</span> <span class='p'>)</span>
  72. </code></pre>
  73. </div>
  74. <h2 id='additems'>addItems</h2>
  75. <div class='highlight'><pre><code class='javascript'><span class='p'>.</span><span class='nx'>isotope</span><span class='p'>(</span> <span class='s1'>&#39;addItems&#39;</span><span class='p'>,</span> <span class='nx'>$items</span><span class='p'>,</span> <span class='nx'>callback</span> <span class='p'>)</span>
  76. </code></pre>
  77. </div>
  78. <p>Adds item elements to the pool of item elements of the container, but does sort, filter or layout. See <a href='adding-items.html'>Adding items</a> for more details. The argument within the callback is the group of elements that were added.</p>
  79. <p><a href='../demos/adding-items.html'><strong>See Demo: Adding items</strong></a></p>
  80. <h2 id='appended'>appended</h2>
  81. <div class='highlight'><pre><code class='javascript'><span class='p'>.</span><span class='nx'>isotope</span><span class='p'>(</span> <span class='s1'>&#39;appended&#39;</span><span class='p'>,</span> <span class='nx'>$items</span><span class='p'>,</span> <span class='nx'>callback</span> <span class='p'>)</span>
  82. </code></pre>
  83. </div>
  84. <p>Adds item elements via <code>addItems</code> method, then triggers <code>layout</code> just for those new elements. Useful for Infinite Scroll. See <a href='adding-items.html'>Adding items</a> for more details.</p>
  85. <p><a href='../demos/adding-items.html'><strong>See Demo: Adding items</strong></a></p>
  86. <h2 id='destroy'>destroy</h2>
  87. <div class='highlight'><pre><code class='javascript'><span class='p'>.</span><span class='nx'>isotope</span><span class='p'>(</span> <span class='s1'>&#39;destroy&#39;</span> <span class='p'>)</span>
  88. </code></pre>
  89. </div>
  90. <p>Removes Isotope functionality completely. Returns element back to pre-init state.</p>
  91. <h2 id='insert'>insert</h2>
  92. <div class='highlight'><pre><code class='javascript'><span class='p'>.</span><span class='nx'>isotope</span><span class='p'>(</span> <span class='s1'>&#39;insert&#39;</span><span class='p'>,</span> <span class='nx'>$items</span><span class='p'>,</span> <span class='nx'>callback</span> <span class='p'>)</span>
  93. </code></pre>
  94. </div>
  95. <p>Appends items elements to container, adds items to via <code>addItems</code> method, and then triggers <code>reLayout</code> method so new elements are properly filtered, sorted and laid-out. See <a href='adding-items.html'>Adding items</a> for more details.</p>
  96. <p><a href='../demos/adding-items.html'><strong>See Demo: Adding items</strong></a>.</p>
  97. <h2 id='layout'>layout</h2>
  98. <div class='highlight'><pre><code class='javascript'><span class='p'>.</span><span class='nx'>isotope</span><span class='p'>(</span> <span class='s1'>&#39;layout&#39;</span><span class='p'>,</span> <span class='nx'>$items</span><span class='p'>,</span> <span class='nx'>callback</span> <span class='p'>)</span>
  99. </code></pre>
  100. </div>
  101. <p>Positions specified item elements in layout.</p>
  102. <p><code>layout</code> will only position specified elements, and those elements will be positioned at the end of layout. Whereas <code>reLayout</code> will position all elements in the Isotope widget.</p>
  103. <h2 id='option'>option</h2>
  104. <div class='highlight'><pre><code class='javascript'><span class='p'>.</span><span class='nx'>isotope</span><span class='p'>(</span> <span class='s1'>&#39;option&#39;</span><span class='p'>,</span> <span class='nx'>options</span> <span class='p'>)</span>
  105. </code></pre>
  106. </div>
  107. <p>Sets options for plugin instance. Unlike passing options through <code>.isotope()</code>, using the <code>option</code> method will not trigger layout.</p>
  108. <div class='highlight'><pre><code class='javascript'><span class='c1'>// sets multiple options</span>
  109. <span class='p'>.</span><span class='nx'>isotope</span><span class='p'>(</span> <span class='s1'>&#39;option&#39;</span><span class='p'>,</span> <span class='p'>{</span> <span class='nx'>layoutMode</span><span class='o'>:</span> <span class='s1'>&#39;fitRows&#39;</span><span class='p'>,</span> <span class='nx'>filter</span><span class='o'>:</span> <span class='s1'>&#39;.my-filter&#39;</span> <span class='p'>}</span> <span class='p'>)</span>
  110. </code></pre>
  111. </div>
  112. <h2 id='relayout'>reLayout</h2>
  113. <div class='highlight'><pre><code class='javascript'><span class='p'>.</span><span class='nx'>isotope</span><span class='p'>(</span> <span class='s1'>&#39;reLayout&#39;</span><span class='p'>,</span> <span class='nx'>callback</span> <span class='p'>)</span>
  114. </code></pre>
  115. </div>
  116. <p>Resets layout properties and lays-out every item element.</p>
  117. <p><a href='../demos/relayout.html'><strong>See Demo: reLayout</strong></a></p>
  118. <h2 id='reloaditems'>reloadItems</h2>
  119. <div class='highlight'><pre><code class='javascript'><span class='p'>.</span><span class='nx'>isotope</span><span class='p'>(</span> <span class='s1'>&#39;reloadItems&#39;</span> <span class='p'>)</span>
  120. </code></pre>
  121. </div>
  122. <p>Re-collects all item elements in their current order in the DOM. Useful for prepending.</p>
  123. <p><a href='../demos/adding-items.html'><strong>See Demo: Adding items</strong></a>.</p>
  124. <h2 id='remove'>remove</h2>
  125. <div class='highlight'><pre><code class='javascript'><span class='p'>.</span><span class='nx'>isotope</span><span class='p'>(</span> <span class='s1'>&#39;remove&#39;</span><span class='p'>,</span> <span class='nx'>$items</span> <span class='p'>)</span>
  126. </code></pre>
  127. </div>
  128. <p>Removes specified item elements from Isotope widget and the DOM.</p>
  129. <h2 id='shuffle'>shuffle</h2>
  130. <div class='highlight'><pre><code class='javascript'><span class='p'>.</span><span class='nx'>isotope</span><span class='p'>(</span> <span class='s1'>&#39;shuffle&#39;</span><span class='p'>,</span> <span class='nx'>callback</span> <span class='p'>)</span>
  131. </code></pre>
  132. </div>
  133. <p>Shuffles order of items. Sets <a href='options.html#sortby'><code>sortBy</code> option</a> to <a href='sorting.html#sortby_option'><code>&#39;random&#39;</code></a>.</p>
  134. <h2 id='updatesortdata'>updateSortData</h2>
  135. <div class='highlight'><pre><code class='javascript'><span class='p'>.</span><span class='nx'>isotope</span><span class='p'>(</span> <span class='s1'>&#39;updateSortData&#39;</span><span class='p'>,</span> <span class='nx'>$items</span> <span class='p'>)</span>
  136. </code></pre>
  137. </div>
  138. <p>Updates the sorting data on specified item elements. This method is useful if the data within an item is changed dynamically after Isotope has been initialized.</p>
  139. <footer>
  140. Isotope by <a href="http://desandro.com">David DeSandro</a> / <a href="http://metafizzy.co">Metafizzy</a>
  141. </footer>
  142. </section> <!-- #content -->
  143. </body>
  144. </html>