简体   繁体   中英

What is the css selector for an element with a class and an attribute in sencha touch

I used to have a code that checks any previous element with a corresponding css class and an attribute which is...

var previousEl = el.prev('.line[@id]');
where line is a class and id is an attribute

this code worked in Ext but when I tried running the same code in sencha-touch, I get a "Error: SYNTAX_ERR: DOM Exception 12".

I checked the dom and I have verified that there is a previous sibling with the class and the attribute id.

Can somebody help me out as to why this selector does not work anymore?

Thanks in advance.

Try dropping the @ ? They took it out from jQuery at some point of time, and reading the Sencha docs it would seem that they did the same in Ext JS.

var previousEl = el.prev('.line[id]');

unlike Ext JS which seems to have its own selector code DomQuery in sencha touch seems to rely on document.querySelectorAll

see the select method in http://dev.sencha.com/deploy/touch/docs/source/DomQuery.html#method-Ext.DomQuery-is

and that method is throwing "SYNTAX_ERR exception if the specified group of selectors is invalid." see https://developer.mozilla.org/En/DOM/Document.querySelectorAll

probably thats the exception you get. try to use selectors that make that function happy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM