submit in for loop does not receive unique name, causing the action to always be executed on the first item

plugin version 1.2.7.2

        list {
		for(r:Reply in s.replies) {
			listitem {
				navigate viewUser(r.author) { output(r.author.name)}
				output(" " + r.message) <br />
				block [class = "like"] {
					output(r.dateTime.format("EEE, d MMM yyyy HH:mm:ss"))
					showLikes(r.likes, r.dislikes)
				}

				if (securityContext.principal.statusUpdates.indexOf(s) != -1 || r.author == securityContext.principal) {
					block  [class = "removeButton"] {
						submitlink removeReply(r) { "x" }
					}
				}
			}
		}
	}

workaround: put the submitlink in a template

        list {
		for(r:Reply in s.replies) {
			listitem {
				navigate viewUser(r.author) { output(r.author.name)}
				output(" " + r.message) <br />
				block [class = "like"] {
					output(r.dateTime.format("EEE, d MMM yyyy HH:mm:ss"))
					showLikes(r.likes, r.dislikes)
				}

				removeTemplate(s,r)
			}
		}
	}


  define removeTemplate(s:StatusUpdate, r:Reply) {
if (securityContext.principal.statusUpdates.indexOf(s) != -1 || r.author == securityContext.principal) {
	block  [class = "removeButton"] {
		submitlink removeReply(r) { "x" }
	}
}
	
action removeReply(r:Reply) {
	s.replies.remove(r);
}
   }
Submitted by Danny Groenewegen on 29 March 2011 at 13:02

On 29 March 2011 at 13:02 Danny Groenewegen tagged 1.2.8

On 4 June 2011 at 12:43 Danny Groenewegen tagged 1.2.9

On 4 June 2011 at 12:43 Danny Groenewegen removed tag 1.2.8

On 24 February 2012 at 17:02 Danny Groenewegen removed tag 1.2.9

On 24 February 2012 at 17:02 Danny Groenewegen tagged 1.3.0

On 3 April 2012 at 21:07 Danny Groenewegen closed this issue.

Log in to post comments