繁体   English   中英

Grails g:each 标签的问题

[英]Problem with Grails g:each tag

我正在努力让 ag:each 标签工作。 我传递给视图的是哈希图列表(类似于 [ [: ], [: ] ] )。 每个 hashmap 的格式为 [location: somelocation, artist: someartist]。 代码如下:

controller中的 CONTROLLER 我正在传递以下内容:

[searchedResults : results.searchedResults]

看法

<g:each status="i" in="${searchedResults}" var="results">
   if(results.location!=null){
       var point${results.location.id} = new google.maps.LatLng(${results.location.lat}, ${results.location.lng});
       var myMarkerOptions${results.location.id} = {
                          position: point${results.location.id}, 
                          map: map
                         };
       var marker${results.location.id} = new google.maps.Marker(myMarkerOptions${results.location.id});   
   }    
</g:each>

任何想法为什么这不起作用? 谢谢!

GrailsGuy 是正确的,因为您不能在每个标签的正文中编写 groovy 代码。 但是让我尝试将其转换为适合您的东西,因为看起来您在那里也做了一些 javascript ......我认为您需要修复的只是您的 if 语句

<g:each status="i" in="${searchedResults}" var="results">
  <g:if test="${results.location}">
    //everything else seems like it would work, assuming your javascript
    // code is accurate
  </g:if>
</g:each>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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