I'm getting a bug from jQuery 1.10.2, the last one, and I would know if anybody have any (other) solution for this issue.
My script create multiple DIV blocks (named items) from one model (item model), add the current after the last one and display it with a "blind" effect.
Here is the code but you can also test it online at this link.
<div id="item_model" style="display: none;" class="item">MODEL</div>
<button class="addBtn">Add 5 items</button>
<script>
$(".addBtn").click(function() {
for( var i=0; i<5; i++ ) {
// Clone model
var p = $("#item_model").clone(true, true);
// Modify item
p.removeAttr("id");
p.text("ITEM n°"+(i+1));
// Add item to the DOM
$(".item").last().after(p);
// Show item
$(p).show("blind");
//$(p).show();
}
});
</script>
The issue is the same with :last and insertAfter().
The logic:
- First item is well displayed and its effect occurred (or not, another bug ? but the time elapses)
- During an effect animation, the element is outsourced ou replaced.
- The next items are inserted out of the DOM (event if after() should insert it in the DOM), so there are not in the page.
This behavior is an error from jQuery but I have to overcome this problem.
The solutions i know:
- Don't use any effect.
- Use a container and append().
- Use slow effect instead of blind. (Thanks to A. Wolff)
- Add elements to the DOM and AFTER, show all. (Thanks to A. Wolff)
Thanks to all for your contribution.