views:

184

answers:

3

I'm trying to select all the <input> elements of a form except ones with IDs containing the words foo or bar. How can I do this using ExtJS 2.3.0? I've tried the following:

Ext.query("select,input:not([id*=foo][id*=bar])", "SomeForm");`

... but it doesn't work. Excluding IDs with foo in them seems to work fine:

Ext.query("select,input:not([id*=foo])", "SomeForm")`

I'm just not sure how to add a second ID substring. Any Ideas?

A: 
Ext.query("select,input:not([id*=foo]):not([id*=bar])", "SomeForm")
Ben
This gives me the following error in FF 3.6.3: `Error parsing selector, parsing failed at "):not([id*=bar]"`. Maybe ExtJS doesn't like chaining pseudo selectors?
pmdarrow
i noticed an opening "select and no closing " please see if that helps
sushil bharwani
See my comment on your original post sushil
pmdarrow
@pmdarrow - That's a perfectly valid CSS3 selector. Maybe you're right, maybe ExtJS doesn't like chaining pseudo selectors.
Ben
A: 

Ext.query("select,input:not([id*=foo]):not([id*=bar])", "SomeForm")` try this

sushil bharwani
Same answer as Ben - see my comment on his.
pmdarrow
notice the closing " please try that
sushil bharwani
I fixed that typo before I even tried it the first time around. It didn't fix anything. Here's the exact line I'm using: `Ext.query("input:not([id*=foo]):not([id*=bar])", "SomeForm");`
pmdarrow
+1  A: 

Not sure how to combine a selector like this but I think if you use the filter function you can filter out the first query:

Ext.DomQuery.filter(Ext.query('input:not([id*=foo])','SomeForm'),'input:not([id*=bar])');

Notice that I just played around a bit more with this and that function works:

Ext.query('input:not([id*=foo]):not([id*=bar])');

but this gives me the same error you mentionned:

Ext.query('input:not([id*=foo]):not([id*=bar])','SomeForm');

So it seems to me like a bug with the ExtJS query function when you pass a specific root with multiple attribute selectors.

SBUJOLD
This works. What if I wanted to exclude IDs containing `baz` in addition to `foo` and `bar`? Also, I seem to get the same error (`Error parsing selector`) when not passing a specific root with `Ext.query("input:not([id*=foo]):not([id*=bar])");` Bear in mind I'm restricted to Ext 2.3.0.
pmdarrow
Sorry I actually read 3.2... if you get the same error I'll assume it's a bug in the 2.3 version then, or maybe it was just not supported. You should be able to call `Ext.DomQuery.filter` on the result of the previous `Ext.Domquery.filter` call and so on. If you have a lot of these I would suggest you create your own function that receives an array of IDs to exclude, does the first `query` call and then loop thru the array of IDs to exclude and call `filter` as often as needed. Unless someone knows a better way using ExtJS, that's what I would do.
SBUJOLD
I just ended up making a loop like you said, but this answer also works so I'll mark it as accepted.
pmdarrow