Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
all values are coming out 'undefined'
var projectsJSON = $.getJSON( 'jsondata.json', function() {
alert("success" + projectsJSON.responseText); //this returns the JSON, pretty sure it is well-formed
});
var portfolio = '<% _.each(projectsJSON, function(projects,index) { %><div id="<%= projects.iimage %>" class="anImage <%= (index)== 0 ? "active visible" : "hidden" %>"><a class="lightbox" href="/images/lightboxed/<%= projects.iimage %>"> <img src="/images/<%= projects.iimage %>" width="844"></a><div class="explanatory_copy"><div class="project_name"><%= projects.pproject_name %></div><div class="project_subtitle"><%= projects.pproject_subtitle %></div><div class="description"><p><%= projects.pproject_desc %></p></div><div class="link_to_more"><a href="<%= projects.iproject %>" rel="address:/<%= projects.iproject %>"><%= projects.ilink_to_more_copy %></a></div><div class="description_more"><p><%= projects.iimagedesc %></p></div></div></div> <% }); %>';
var templateOutput = _.template(portfolio, { projects : projectsJSON }); //this is the line I think is probably wrong
$('.slides_container').html(templateOutput);
//I get 'undefined' for all the interpolated values when I output the template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment