How to listen a event when when user delete node using key or button

Hi,

In JS file of the custom node i want clear the interval of function when user remove/delete custom node in node red

I already add this code - >

this.on('close', function(removed, done) {
			if (removed) {
				if(interval) {
					clearInterval(interval);
					timer = false;
				}
			}
			done();
		});
1 Like

I also need this...

in the example @kiran posted, it might have been that interval was not accessible.

try adding this to your custom node - see if you get a log entry....

this.on('close', function(removed, done) {
	console.log("this.on('close') happened!")
	if (removed) {
		console.log("node was removed!")
	}
	done();
});

NOTE: done() is a relatively new parameter - you should check it is available before calling it)

1 Like