So I have a modal. that when triggered fetches. 1 JSON file. The JSON has multiple nodes; however, I just want to target the last 4 nodes and omit anything before it. The name of these nodes are: post_a, post_b, post_c, post_d.
They will always be the last 4 nodes in the array. That's the best logic I can think of :c
I'm at the very last interaction of my portfolio and I'm so stumped on how to traverse through just these 4 nodes. I understand that it will wonkey logic and I'm ok with this. I'm pretty far down the rabbit hole and now and I just want it to work. :(
Sample JSON file:
{
created_at: "2013-07-15T05:58:25Z",
id: 21,
name: "Skatelocal.ly",
svg: "<svg> ... </svg>",
post_a: "This is an awesome post 1",
post_b: "This is an awesome post 2",
post_c: "this is an awesome post 3",
post_d: "this is an awesome post 4"
}
Here are the triggers as well as JSfiddle of how it should traverse:
JSFIDDLES
postInModal = function(data, status) {
$(".next").on({
click: function() {
//jsfiddles has working interaction dont want to cludder
$(".modal-main").hide().html(data.post_X).fadeIn()
}
});
return $(".prev").on({
click: function() {
//jsfiddles has working interaction dont want to cludder
$(".modal-main").hide().html(data.post_X).fadeIn()
}
});
};
return popProject = function(x) {
return $.ajax({
type: "GET",
url: "/works/" + x + ".json",
success: postInModal
});