Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery .each() callback function doesn't run on each iteration/loop
    primarykey
    data
    text
    <p><strong>Here's what should happen.</strong><br> 1. Get the rel attribute of the clicked link<br> 2. For every div with class 'entry':<br> (i)Get its 'left' position<br> (ii) Calculate its outer height<br> (iii)Loop through all instances of 'a.tag_filter'. If it finds the same string in the 'rel' as the one oringinally clicked on then add 1 to 'V' and break out of the loop.<br> (iv)If 'V' is equal to 0 after the loop we know the same tag isn't present within that '.entry' so fade it out.<br> (v)Once the fadeout has finished loop through all the '.entry' after the faded out one and get their 'left' values.<br> (vi)If the left value of the faded entry = the left value of the current '.entry' then reposition it to the new 'top' value.</p> <p><strong>What is currently happening.</strong><br> It runs through and fades out all the correct '.entry' elements and only after all of them have faded out does it reposition them remaining '.entry' elements.</p> <p>After each element is faded out I would like the repositioning loop to run so it essentially positions the remaining elements one at a time rather than all at once.</p> <p><strong>Heres my code EDIT:</strong></p> <pre><code>$('a.tag_filter').click(function(e){ e.preventDefault(); var selectTag = $(this).attr('rel'); $('div.spotlight_entry_container_grid').each(function(i){ var $entry = $(this); var tagArray = []; $('a.tag_filter', this).each(function(){ tagArray.push ($(this).attr('rel')); }); if($.inArray(selectTag,tagArray) == -1){ var leftPos = $entry.css("left"); var topPos = $entry.css("top"); $entry.fadeOut(1000, function(){ var nextLeftPos; var nextTopPos; $('div.spotlight_entry_container_grid:gt('+i+')').each(function(j) { var $laterEntry = $(this); nextLeftPos = $laterEntry.css("left"); nextTopPos = $laterEntry.css("top"); //we need to keep the entries in their columns. //matching left values will do it. No need to animate left values. if(leftPos == nextLeftPos){ $laterEntry.animate({ top: topPos}); } }); }); } }); }); </code></pre> <p>Hopefully that makes sense<br> Any help would be appreciated! I'm probably doing something crazy but I just can't spot it. Thanks</p>
    singulars
    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.
    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.
 

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