PDA

View Full Version : 'ref' buttons by classname (in a controller)



jeanluca
17 Sep 2012, 11:59 PM
Hi

I have two logout buttons (each on a different panels), for which I want to do something when they're tapped. I have added a class value of 'logout' to both of them and the following controller setup:



.....
ref: {
logoutButtons: 'button[class~="logout"]' // should match both buttons
},
control: {
logoutButtons: {
tap: 'onLogout'
}
}
....

Well, this doesn't work, any suggestions how to fix this ?

Thanks
Luca

netresource
18 Sep 2012, 1:24 AM
you can do below

refs: {
logoutButton:{
selector: '[cls="logout"]'
}
},
control: {
logoutButton:{
tap: 'onLogoutTap'
}
}

jeanluca
18 Sep 2012, 1:48 AM
check, it works now! Thanks a lot!!

trevorcox
2 Oct 2014, 5:07 PM
Worked for me in 2.2.1; now broken in 2.4. I switched to creating a button with its own xtype.

Keab42
6 Oct 2014, 6:03 AM
They've changed the functionality of searching by cls selectors in 2.4. It seems that it now searches for the full cls string which invariably also adds a few x- classes from the framework. 2.4.1 will apparently contain a fix for this: http://www.sencha.com/forum/showthread.php?292819-Component-Query-and-Refs-by-Class

tt1987
7 Oct 2014, 7:05 AM
you can do belowCode: refs: { logoutButton:{ selector: '[cls="logout"]' } }, control: { logoutButton:{ tap: 'onLogoutTap' } }thank you I did not succeed