Skip to content

Commit

Permalink
Use the new updateNode in the nodedrop handler
Browse files Browse the repository at this point in the history
Instead of a separate Ajax call, just use the updateNode method and pass the
new :parent_id for the node.
  • Loading branch information
Daniel Martin committed Jul 5, 2011
1 parent c6cc95b commit c1c010f
Showing 1 changed file with 2 additions and 22 deletions.
24 changes: 2 additions & 22 deletions public/javascripts/nodestree.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ dradis.NodesTree = Ext.extend(Ext.tree.TreePanel, {
this.on('nodedrop', function(ev) {
var point = ev.point;
var node = ev.dropNode;
var p = { };
var p = { parent_id: null };
if ( point == 'append') {
p.parent_id = ev.target.id;
} else {
Expand All @@ -248,27 +248,7 @@ dradis.NodesTree = Ext.extend(Ext.tree.TreePanel, {
p.parent_id = parent.id;
}
}
Ext.Ajax.request({
url: 'nodes/' + node.id + '.json',
method: 'put',
params: {
data: Ext.util.JSON.encode(p)
},
success: function(response, options) {
dradisstatus.setStatus({
text: 'Node repositioned',
clear: 5000
});
},
failure: function(response, options) {
dradisstatus.setStatus({
text: 'An error occured with the Ajax request',
iconCls: 'error',
clear: 5000
});
}
});

this.updateNode(node, p)
});

// ==================================================== /event handlers
Expand Down

0 comments on commit c1c010f

Please sign in to comment.