I have a view template that displays a number of images. It contains a button which drives a popup that contains the AddEdit view:
#renderView(view='Administration/images/image')#
This is fine. However I also want to have an edit button for each image. Here is my (unfinished) code:
#renderView(view='Administration/images/image', collection=prc.images)#
I assume I need to do something inside the loop in order to pass the imag_ky to the popupEdit. But how do I do that?
Should I be using the collection attribute of renderView()? Is there a problem with the ID of the divs because they should by right be unique, and I fear that CB is creating more than one of them in the background?
Does someone know an easy way to do this?
You haven’t said what’s happening wrong with that code, so I’m not sure how to help you. I don’t think you want to use collection. It’s meant to basically loop through an array or query and render a view once for each item/index.
Looking at your code I’m guessing you want to have two hidden divs when the page loads-- an add form and an edit form, and then show one as appropriate so the user can add an image or edit an existing one. That should work, but you’ll need to have some JS when they click edit that populates a hidden field or something with the ID and information of the image being edited.
I would recommend viewing the source code of the page after the browser renders to see what’s going on.
Thanks!
~Brad
ColdBox Platform Evangelist
Ortus Solutions, Corp
E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com