PDA

View Full Version : dataView - same click listener with different fn for different delegates



geo_cris_ro
18 Feb 2010, 6:59 AM
Hello!

Is it possible to add a listener("Click" for example) and set it different for different delegates?

For example:



new Ext.DataView({
store: this.store,
tpl: this.tpl,
listeners: {
'click' : {fn:this.f1, scope:this, buffer:100, delegate: 'img.class1'},
}
});


Here I want to add the listener click with other handler for a different delegate.
Is there an easy way to do this in a similar way?


Thank you!

geo_cris_ro
19 Feb 2010, 12:18 AM
I found a solution to solve my problem:


this.view = new Ext.DataView({
store: this.store,
tpl: this.tpl,
overClass:'x-view-over',
itemSelector:'div.scene2-wrap',
listeners: {
'click' : {fn:this.f1, scope:this, buffer:100, delegate: 'img.btn1'}
,'render' : {fn:function(){
var e = Ext.select('.edit-btn', true).elements;
for(var i = 0; i < e.length; i++)
e[i].on('click', function(){ this.edit(); }, this);}
, scope:this}
var e = Ext.select('.delete-btn', true).elements;
for(var i = 0; i < e.length; i++)
e[i].on('click', function(){ this.delete(); }, this);}
, scope:this}
},
}
}
});

Now I can add different 'click' handlers inside a view node.

geo_cris_ro
19 Feb 2010, 12:22 AM
this.view = new Ext.DataView({
store: this.store,
singleSelect: true,
tpl: this.tpl,
overClass:'x-view-over',
itemSelector:'div.scene2-wrap',
listeners: {
'dblclick' : {fn:this.fullPreview, scope:this, buffer:100}//{fn:this.doCallback, scope:this},
,'render' : {fn:function(){
var e = Ext.select('.edit-btn', true).elements;
for(var i = 0; i < e.length; i++)
e[i].on('click', function(){ this.edit(); }, this);}
, scope:this}
var e = Ext.select('.delete-btn', true).elements;
for(var i = 0; i < e.length; i++)
e[i].on('click', function(){ this.delete(); }, this);}
, scope:this}
}
}
});