     #ev.target.appendChild(data);
     container = $(ev.currentTarget)
 
-    #debugger
     if @dragged.attr('data-block')
       tmpl = @handleBlock @dragged.data('block')
       @dropBlock(container, tmpl)

    _.each $('.tpl-container'), (n)->
      $(n).find(".legend").remove()


  drag: (ev)->
    #console.log(ev.currentTarget)
    @dragged = $(ev.currentTarget)


    @releaseBeforeItem()

    @displayEmptyBlocks()

  dropBlock: (container, tmpl)->
    #drop on before item or in tpl-container
    if $(".tpl-block.dojoDndItemBefore").length > 0
      container.find(".tpl-block.dojoDndItemBefore").before(tmpl)
      container.find('.mojoMcContainerEmptyMessage').hide()
    else
      container.find(".tpl-container").append(tmpl)
      #container.find('.mojoMcContainerEmptyMessage').hide()

  releaseBeforeItem: ()->
    $(".tpl-block").removeClass("dojoDndItemBefore")
