if(event.type === 'metadataRemoved' && event.meta.node.sameNode(currentNode)) {
view.removeMetadataRow(event.meta.row);
}
- if(event.type === 'nodeDetached' && event.meta.node.sameNode(currentNode)) {
+ if(event.type === 'nodeDetached' && event.meta.node.containsNode(currentNode)) {
view.setMetadata(null);
}
});
return function(sandbox) {
- var template = _.template(templateSrc);
+ var template = _.template(templateSrc),
+ listens = false;
var view = {
dom: $('<div>' + template({node:null, parents: null}) + '</div>'),
start: function() { sandbox.publish('ready'); },
getView: function() { return view.dom; },
setNodeElement: function(nodeElement) {
+ if(!listens && nodeElement) {
+ nodeElement.document.on('change', function() {
+ if(view.currentNodeElement && !view.currentNodeElement.isInDocument()) {
+ view.setNodeElement(null);
+ }
+ });
+ listens = true;
+ }
view.setNodeElement(nodeElement);
},
highlightNode: function(id) { view.highlightNode(id); },
var module = this;
if(!listens) {
wlxmlNodeElement.document.on('change', function(event) {
+ if(currentNode && !currentNode.isInDocument()) {
+ module.setNodeElement(null);
+ }
if(event.type === 'nodeAttrChange' && event.meta.node.sameNode(currentNode)) {
module.setNodeElement(currentNode);
}