 # Calls given callback with the hash as an argument
 # Currently uses mockmule.
 getMuleKeys = (fn) ->
-  url = "http://localhost:3000/key?jsonp=callback"
-  window.callback = (response) ->
-      keys = response.data
-      fn(keys)
+  url = "http://localhost:3000/key?jsonp=muleviewCallback"
+  window.muleviewCallback = (response) ->
+      fn(response.data)
+      delete window.muleviewCallback
   scriptTag = document.createElement("script")
   scriptTag.src=url
   scriptTag.type="text/javascript"


Ext.define "KeyModel",
  extend: "Ext.data.Model"
  fields: ["name"]

treeStore = Ext.create "Ext.data.TreeStore",
  model: "KeyModel"

  width: "20%"
  split: true
  displayField: "name"
  listeners:
    selectionchange: (me, selected) ->
      console.log('muleview.coffee\\ 32: selected[0].get("fullname"):', selected[0].get("fullname"));
  # rootVisible: false
  store: treeStore

