In my grails template I call the remoteFunction (using jquery library) onload. To test if it worked, I wrote a println in the action. Turns out, it did work, but only one print statement went through instead of multiple print statements appearing in the console for the multiple items in my collection.
Here are my code snippets
gsp:
<figcaption id="secondcap">
<img id="changer" src="${resource(dir: "images/images", file: "heart.png")}" onload="${remoteFunction(controller:'user', action: 'hasHearted')}" alt="heart">
</figcaption>
groovy:
def hasHearted = {
println "Recieved user ID:"
}
I guess you use the same image for every element
so your browser caches it and makes only one call to your server.
You can verify this in network tab in Firebug og chrome dev tools.
Try to turn off browser cache – in FF webdeveloper addon can do that in easy way.