I have a for loop to loop through my list of SliderItems which contain an ID, ImageUrl, and a link Url.
<% foreach (var item in Model) { %>
<a href="#"><img id="<%: item.ImageID %>" src="<%: item.ImageUrl %>" class="slide" alt="" /></a>
<%} %>
I need to loop through and generate the data parameters for this javascript automatically in a similar fasion, replacing the "slide-img-#" with my SliderItem.ID
<script type="text/javascript">
if (!window.slider) var slider = {}; slider.data = [{ "id": "slide-img-1" }, { "id": "slide-img-2" }, { "id": "slide-img-3" }, { "id": "slide-img-4"}];
</script>
Whats the best way to go about this?