Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I found a rational (if intricate) explanation for your bug.</p> <p>The root cause : you are using a <code>jquery-ui</code> effect (not a basic <code>jquery</code> effect), and you add elements after last inserted item, before the animation has finished.<br> The gotcha : jquery-ui uses wrappers during its animations, and if a wrapper is already present, it reuses it.</p> <p>Here is the detailed walkthrough :</p> <ul> <li>When animating the first item : for the duration of the effect, the item is wrapped in a div with class <code>ui-effects-wrapper</code>, and this wrapper div is animated to give the <code>blind</code> effect</li> <li>When adding the second item : adding it after "last" (&lt;- in this case : the first item) actually adds it inside the wrapper. </li> <li>When animating the second item: jquery-ui reuses the existing wrapper (shortcut in <code>createWrapper</code>, see below)</li> <li>Same goes for items 3-5</li> <li>When first animation ends, the wrapper element is removed and replaced whith the first animated elements. The other elements (remember : they were attached as children of this wrapper) end up dangling with no parent.</li> </ul> <p>Relevant pieces of code :<br> <a href="https://github.com/jquery/jquery-ui/blob/9470af0bbefafa3d81c3709674a45a54b693e7cf/ui/jquery.ui.effect-blind.js#L21" rel="nofollow noreferrer">jquery-ui code : snippet 1 - <code>blind()</code> function</a><br> <a href="https://github.com/jquery/jquery-ui/blob/9470af0bbefafa3d81c3709674a45a54b693e7cf/ui/jquery.ui.effect.js#L959" rel="nofollow noreferrer">jquery-ui code : snippet 2 - <code>createWrapper()</code> inner function</a><br> <a href="https://github.com/jquery/jquery-ui/blob/9470af0bbefafa3d81c3709674a45a54b693e7cf/ui/jquery.ui.effect-blind.js#L75" rel="nofollow noreferrer">jquery-ui code : snippet 3 - <code>blind()</code> code when animation completes</a> </p> <p>I don't think this should be considered as a jquery-ui bug - your use case is, IMHO, pretty isolate, and I wouldn't imagine what "correcting" this would trigger elsewhere.</p> <p>Solutions :</p> <ul> <li><code>slideDown</code> will work (<a href="http://jsfiddle.net/AN3ft/4/" rel="nofollow noreferrer">fiddle</a> - it animates the element, no wrapper there)</li> <li>add a <code>&lt;span id="beacon"&gt;&lt;/span&gt;</code> item and insert new elements <em>before</em> <code>#beacon</code></li> <li><a href="https://stackoverflow.com/a/18955256/86072">A. Wolff's solution</a></li> <li>as you already found out, <code>.append()</code> on a common container</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload