             directory.on 'all', @render
             @shards = []
 
+        bind_edit_machines: (shard) ->
+            # TODO: deal with this later
+            @.$('#assign_master_' + shard.index).click (e) =>
+                e.preventDefault()
+
+            # Fucking JS closures
+            bind_shard = (shard, secondary) =>
+                @.$('#assign_machines_' + shard.index + '_' + secondary.datacenter_uuid).click (e) =>
+                    e.preventDefault()
+                    modal = new NamespaceView.EditMachinesModal @model, _.extend secondary,
+                        name: shard.name
+                        shard: shard.shard
+                    modal.render()
+
+            for secondary in shard.secondaries
+                bind_shard shard, secondary
+
         render: =>
             log_render '(rendering) namespace view: shards'
 


            # Bind events to 'assign machine' links
            for shard in shards_array
                @.$('#assign_master_' + shard.index).click (e) =>
                    e.preventDefault()
                for secondary in shard.secondaries
                    @.$('#assign_machines_' + shard.index + '_' + secondary.datacenter_uuid).click (e) =>
                        e.preventDefault()
                        modal = new NamespaceView.EditMachinesModal @model, _.extend secondary,
                            name: shard.name
                            shard: shard.shard
                        modal.render()

            return @


                        clear_modals()
                        return
                    output = {}
                    output[@secondary.shard] = _.union (_.map pinned_machines, (m)->m.value), @get_currently_pinned()
                    output =
                        secondary_pinnings: output
                    $.ajax
