               taxon_tree_menu(obj, this)
           plugins: ["themes", "json_data", "dnd", "crrm", "contextmenu"]
 
-        $("#taxonomy_tree").jstree(conf)
+        $taxonomy_tree.jstree(conf)
           .bind("move_node.jstree", handle_move)
           .bind("remove.jstree", handle_delete)
           .bind("create.jstree", handle_create)

          .bind "loaded.jstree", ->
            $(this).jstree("core").toggle_node($('.jstree-icon').first())

    $("#taxonomy_tree a").on "dblclick", (e) ->
      $("#taxonomy_tree").jstree("rename", this)

    # surpress form submit on enter/return
    $(document).keypress (e) ->


root = exports ? this
root.setup_taxonomy_tree = (taxonomy_id) ->
  $taxonomy_tree = $("#taxonomy_tree")

  if taxonomy_id != undefined
    # this is defined within admin/taxonomies/edit
    root.base_url = Spree.url(Spree.routes.taxonomy_taxons_path)
