PDA

View Full Version : [CLOSED][3.0] Ext.select is broken



mschwartz
15 Apr 2009, 11:36 AM
var buttons = Ext.select('a.buttonson', true);
for (var i = 0; i < buttons.elements.length; i++) {
var button = buttons.elements[i];
button.blur();
button.replaceClass('buttonson', 'buttons');
}


Error: button.replaceClass is not a function

I examine buttons in firefox and it's now a CompositeElement:
buttons[] :
--- el
------ isFlyweight: true
------ replaceClass: function() <--- ok, so it's moved, right?
--- elements[] :
------ clientLeft: 1 <--- it's a DOM node, not an Ext.Element anymore

So I read the docs on CompositeElements and I modify my code thus:


var buttons = Ext.select('a.buttonson', true);
// new 3.0 code
buttons.el.replaceClass('buttonson', 'buttons');
// old 2.2 code
//for (var i = 0; i < buttons.elements.length; i++) {
// var button = buttons.elements[i];
// button.blur();
// button.replaceClass('buttonson', 'buttons');
//}


This throws an error, too:
line 3527 ext-all-debug.js


removeClass: function(className) {
var me = this;
if (me.dom.className) {


Examine 'me' and dom is 'undefined', isFlyweight=true

So what is the bug I'm reporting?

This line, the 'true' argument is being ignored or not behaving like 2.2 or the 3.0 docs say it should:

var buttons = Ext.select('a.buttonson', true);

mschwartz
15 Apr 2009, 11:38 AM
buttons.replaceClass() works, btw.

evant
15 Apr 2009, 12:33 PM
elements is an private property, it retrns a series of DOM elements.

You should use:



Ext.select('div.foo').each(function(el){
el.blur();
el.replaceClass('foo', 'bar');
});