簡體   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