2012-08-03 87 views
0

我是YUI(AUI)初学者。在jQuery中,我会做YUI嵌套选择器

$(image).find(selector).text(); 

这怎么能在YUI中实现?

AUI().use('event', 'node', function(A) { 

var subImages = A.all('.sub_image_conatiner'); 
for (var i = 0; i < subImages.size(); i++){ 

    var image = subImages.get(i); 
    //get child elements of image here 
} 
}); 

回答

0

我以为Y.all(foo).all(selector).get('text')只会工作,但不幸的是没有。

我建议您只使用一个选择相匹配的子元素:

Y.all('.parent-class .child-class').get('text'); 

如果你不能,那么你不必通过像一个正常的JS数组的节点进行迭代。您可以使用.each()

var texts = []; 
Y.all(foo).each(function (node, i) { 
    texts = texts.concat(node.all(bar).get('text')); 
}); 
console.log(texts); 

我会提交一个bug与YUI,看它是否有道理添加Y.NodeList.prototype.all