Search code examples
jqueryeffecttransfer

Finish "transfer" before adding text


I am adding a list with jquery effect transfer. I want to make the text - "element" appear only after the transfer effect is completely finished. Any idea? Thanks,

<script type="text/javascript">
$(document).ready(function(){
    $("#add-li").click(function(){
        var NewLI = document.createElement("li");
        var ul = document.getElementById("ul");
        NewLI.innerHTML = 'element';
        ul.appendChild(NewLI);

        $("#add-li").effect("transfer", { to: $("#ul li:last-child"), className: "ui-effects-transfer" }, "slow");
        })})
</script>
<style type="text/css">
.ui-effects-transfer { border: 2px dotted #FFE600; }
</style>
</head>

<body>
<p><input type="button" id="add-li" value="add list" /></p>
<br /><br /><br /><br /><br /><br /><br />
<p>
    <div id="effect">Below this the list.
    <ul id="ul">
    </ul>
    </div>
</p>
</body>

Solution

  • That sucks! It seems that the effect you are using doesn't have option to callback. http://docs.jquery.com/UI/Effects/Transfer

    This one has got callback http://api.jquery.com/animate/

    More examples about callback http://api.jquery.com/slideDown/