Created
December 10, 2012 21:47
-
-
Save davidrhoden/4253671 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var render = function (data) { | |
var portfolio = '<% _.each(data, function(project,index) { %><div id="<%= project.iimage %>" class="anImage <%= (index)== 0 ? "active visible" : "hidden" %>"><a class="lightbox" href="/images/lightboxed/<%= project.iimage %>"> <img src="/images/<%= project.iimage %>" width="844"></a><div class="explanatory_copy"><div class="project_name"><%= project.pproject_name %></div><div class="project_subtitle"><%= project.pproject_subtitle %></div><div class="description"><p><%= project.pproject_desc %></p></div><div class="link_to_more"><a href="<%= project.iproject %>" rel="address:/<%= project.iproject %>"><%= project.ilink_to_more_copy %></a></div><div class="description_more"><p><%= project.iimagedesc %></p></div></div></div> <% }); %>'; | |
var p_id = 4; //this will be a changing value when the filter works | |
var selectedProject = _.filter(data, function(p_id){ return data.iproject === p_id } ); | |
console.log(p_id, data, 'selectedProject:', selectedProject); // returns p_id and data correctly, and nothing for selectedProject | |
var templateOutput = _.template(portfolio, { data : selectedProject }); | |
//var templateOutput = _.template(portfolio, { data : data }); returns all data, this works | |
$('.slides_container').html(templateOutput); | |
}; | |
$.getJSON('jsondata121201.json', render); //checked, this is valid JSON |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment