I'm trying to remove jquery from my Angular.js app in order to make it lighter, and put Angular's jqLite instead. But the app makes heavy use of find('#id') and find ('.classname'), which are not supported by jqLite, only 'tag names' (as per documentation)
wondered what do u feel would be the best approach to change it. One approach I thought about is to create custom HTML tags. for example:
change
<span class="btn btn-large" id="add-to-bag">Add to bag</span>
to
<a2b style="display:none;"><span class="btn btn-large" >Add to bag</span></a2b>
and
$element.find('#add-to-bag')
to
$element.find('a2b')
Any thoughts? other ideas?
thanks
Lior
DomElement.querySelector(".myclassname")
to select a single decendant element using a css selector, or all matching by adding All to it:DomElement.querySelectorAll(".myclassname")
That of course doesn't work in IE<9. – Shavena2b
element, you must have defined a directive. Can you do what needs to be done in the link function of the directive, and therefore avoid the need to call find() entirely? Similarly with your classes -- can you define directives and put the functionality you need into the directives' link (or compile) functions? – Moneywort.find
in jqLite doesn't support the.btn
portion of that string – Shavenelement
is the DOM element (wrapped in jQuery or jqLite). – Moneywort$element.find('span.btn');
[]$element.find('a2b');
[ <a2b style="display:none;">…</a2b> ] – Crepuscule