PDA

View Full Version : Listener Not Working



Hook
30 Apr 2011, 9:12 AM
I have an app doing some drag/drop from a tree to a grid panel. When dragging from the grid to the tree, I use the following code to create the tree node:

var onBeforeDropProductOnTree = function(event) {
var record = event.data.selections[0];

event.dropNode = new Ext.tree.TreeNode({
listeners: treeListeners.getListeners(),
text: record.get('name'),
meta: {
id: record.get('id'),
type: 'product',
disabled: false
},
leaf: true
});
onDropProduct(event);
return true;
}

But none of the listeners are working. Since the listeners include contextmenu, I checked for its presence like so:

var onDropProductSuccess = function(response, options) {
var responseJson = Ext.decode(response.responseText);

this.dropNode.setId(responseJson.productId);
this.parent.expand(null, null, function() {
this.parent.insertBefore(this.dropNode, this.before);
nodeProps.incrRefCount(this.dropNode);
alert('contextmenu: ' + this.dropNode.hasListener('contextmenu'));
}, this);
}

I see from the alert that the contextmenu listener is present, but the element is not responding.

I've spent a day on this, trying various thing, but with no luck. I don't even know where to look next. Any ideas?

--
JR

Hook
2 May 2011, 9:57 AM
I eventually found the problem, so I wanted to post it here, in case anyone else runs into this problem.

Turns out that a typo was causing the setId to set an undefined value. Once I fixed that, the contextmeny started working.

This was a bear to find.

--
JR