Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExtJS remove listener

I'm having difficulty getting this to work:

var fn = function(){};

Ext.select('ul > li').on('click',fn);
// works

Ext.select('ul > li').un('click',fn);
//doesn't work

'un'/'removeListener' does not work. Appreciate any help!

like image 733
Prabath Yapa Avatar asked Dec 08 '11 13:12

Prabath Yapa


1 Answers

By default, Ext.select creates a flyweight object, which does not remember event listeners. Thus, they cannot be removed later.

You need to create real Ext.Elements by setting the second parameter to true:

var fn = function(){};

Ext.select('ul > li', true).on('click',fn);

Ext.select('ul > li', true).un('click',fn);

Unfortunately, the docs are not very clear about this.

like image 186
user123444555621 Avatar answered Nov 10 '22 08:11

user123444555621