我正在尝试通过Polymer.dom(this.root).querySelectorAll("#office-cities-acc .city");
访问.city元素但它没有返回任何内容。我认为这是因为这些元素是通过dom-repeat动态创建的。是这样吗?有什么方法可以访问它们?
<template>
<iron-ajax
auto url="@{Office.getOffices}" params='{"alt":"json", "q":"polymer"}'
handle-as="json" last-response="{{ajaxResponse}}"></iron-ajax>
....
<div class="office-cities-list">
<div class="panel-group" id="office-cities-acc">
<template is="dom-repeat" items="[[ajaxResponse.officesRegions]]"
as="region">
<template is="dom-if" if= "{{checkRegionType(region.type)}}">
<div class="panel panel-default">
<div class="panel-heading">
...
</div>
<div id="{{computeUrl(region.regionsId)}}"
class="panel-collapse collapse">
<div class="panel-body">
<ul>
<template is="dom-repeat" items="[[ajaxResponse.officesCities]]"
as="city">
<template is = "dom-if" if="{{checkCityRegion(region.regionsId,city.regionsId)}}">
<li class="city"><a href="#"
data-city-name$={{getNameByLang(city)}}>{{getNameByLang(city)}}</a></li>
</template></template>....
</template>