 
     tpl.on 'replace', (el, tag) ->
         delay.call el, ->
-            el._jquery.replaceWith(tag._jquery ? tag)
+            nextAnimationFrame ->
+                el._jquery.replaceWith(tag._jquery ? tag)
 
     tpl.on 'remove', (el) ->
         el._jquery?.remove()


    tpl.on 'raw', (el, html) ->
        delay.call el, ->
            el._jquery.html(html)

    tpl.on 'show', (el) ->
        delay.call el, ->

        delay.call parent, ->
            if parent is tpl.xml
                parent._jquery = parent._jquery.add(el._jquery)
                parent._jquery.data('dt-jquery', parent)
            else
                nextAnimationFrame ->
                    parent._jquery.append(el._jquery)

    tpl.on 'close', (el) ->
        el._jquery ?= $(el.toString())
