         e.preventDefault()
         $node = $(e.currentTarget).closest('.node')
         @select $node
+        @tree.trigger "nodeselected", [$node, $node.data("node")]
 
 
   refresh: (opts) ->

        dataType: "json"
        success: (result) =>
          @_renderTree @tree, result
    else
      @_renderTree @tree, @opts.items

    @_bind()



  select: ($node) ->
    if $node
      $node = @tree.find('.node[data-id=' + $node + ']') unless typeof $node is 'object'
      return unless $node.length > 0

      @tree.find('.node.selected').removeClass('selected')
      $node.addClass('selected')
    else
      $node = @tree.find('.node.selected')

