Skip to content

Instantly share code, notes, and snippets.

@kirstilynn
Created November 22, 2013 18:05
Show Gist options
  • Save kirstilynn/7604266 to your computer and use it in GitHub Desktop.
Save kirstilynn/7604266 to your computer and use it in GitHub Desktop.
define(['jquery','modules/renderAds'], function ($, renderAds) {
renderAds('#columns');
});
{
"ads":[
{
"id" : "1",
"url" : "/1-silk-scarf",
"name" : "Super cute silk scarves",
"image" : "../images/scarf.jpg",
"price" : "24",
"location" : "Springville, UT",
"watching" : "0"
},
{
"id" : "2",
"url" : "/2-weird-shirt",
"name" : "Weird aztec eye shirt. Pants not included.",
"image" : "../images/girl.jpg",
"price" : "8",
"location" : "Provo, UT",
"watching" : "0"
},
{
"id" : "3",
"url" : "/3-kids-room-table-and-chairs",
"name" : "Kids room table and chairs.",
"image" : "../images/tabels.jpg",
"price" : "45",
"location" : "Orem, UT",
"watching" : "0"
},
{
"id" : "12",
"url" : "/12-sweet-metal-piggy-bank",
"name" : "Sweet metal piggy bank.",
"image" : "../images/pig.jpg",
"price" : "22",
"location" : "Pleasant Grove, UT",
"watching" : "0"
},
{
"id" : "25",
"url" : "/25-delicious-peach-lemonade",
"name" : "Delicious peach lemonade.",
"image" : "../images/lemonade.jpg",
"price" : "6",
"location" : "Spanish Fork, UT",
"watching" : "0"
},
{
"id" : "28",
"url" : "/28-love-christmas-tree-ornament",
"name" : "LOVE Christmas Tree ornament.",
"image" : "../images/love.jpg",
"price" : "13",
"location" : "North Pole, Earth",
"watching" : "0"
},
{
"id" : "1",
"url" : "/1-silk-scarf",
"name" : "Super cute silk scarves",
"image" : "../images/scarf.jpg",
"price" : "24",
"location" : "Springville, UT",
"watching" : "0"
},
{
"id" : "2",
"url" : "/2-weird-shirt",
"name" : "Weird aztec eye shirt. Pants not included.",
"image" : "../images/girl.jpg",
"price" : "8",
"location" : "Provo, UT",
"watching" : "0"
},
{
"id" : "3",
"url" : "/3-kids-room-table-and-chairs",
"name" : "Kids room table and chairs.",
"image" : "../images/tabels.jpg",
"price" : "45",
"location" : "Orem, UT",
"watching" : "0"
},
{
"id" : "12",
"url" : "/12-sweet-metal-piggy-bank",
"name" : "Sweet metal piggy bank.",
"image" : "../images/pig.jpg",
"price" : "22",
"location" : "Pleasant Grove, UT",
"watching" : "0"
},
{
"id" : "25",
"url" : "/25-delicious-peach-lemonade",
"name" : "Delicious peach lemonade.",
"image" : "../images/lemonade.jpg",
"price" : "6",
"location" : "Spanish Fork, UT",
"watching" : "0"
},
{
"id" : "28",
"url" : "/28-love-christmas-tree-ornament",
"name" : "LOVE Christmas Tree ornament.",
"image" : "../images/love.jpg",
"price" : "13",
"location" : "North Pole, Earth",
"watching" : "0"
},
{
"id" : "1",
"url" : "/1-silk-scarf",
"name" : "Super cute silk scarves",
"image" : "../images/scarf.jpg",
"price" : "24",
"location" : "Springville, UT",
"watching" : "0"
},
{
"id" : "2",
"url" : "/2-weird-shirt",
"name" : "Weird aztec eye shirt. Pants not included.",
"image" : "../images/girl.jpg",
"price" : "8",
"location" : "Provo, UT",
"watching" : "0"
},
{
"id" : "3",
"url" : "/3-kids-room-table-and-chairs",
"name" : "Kids room table and chairs.",
"image" : "../images/tabels.jpg",
"price" : "45",
"location" : "Orem, UT",
"watching" : "0"
},
{
"id" : "12",
"url" : "/12-sweet-metal-piggy-bank",
"name" : "Sweet metal piggy bank.",
"image" : "../images/pig.jpg",
"price" : "22",
"location" : "Pleasant Grove, UT",
"watching" : "0"
},
{
"id" : "25",
"url" : "/25-delicious-peach-lemonade",
"name" : "Delicious peach lemonade.",
"image" : "../images/lemonade.jpg",
"price" : "6",
"location" : "Spanish Fork, UT",
"watching" : "0"
},
{
"id" : "28",
"url" : "/28-love-christmas-tree-ornament",
"name" : "LOVE Christmas Tree ornament.",
"image" : "../images/love.jpg",
"price" : "13",
"location" : "North Pole, Earth",
"watching" : "0"
}
]
}
{{#ads}}
<div class="helload">
<a href="{{url}}"><img src={{image}}>
<div class="adtitle">{{name}}</div>
</a>
<div class="adspecifics">
<div class="adicons left">
<a href="#"><i class="fa fa-eye"></i></a> <a href="#"><i class="fa fa-mobile-phone"></i></a>
</div>
<div class="costlocation right">
<h2>${{price}}</h3>
<h3>{{location}}</h3>
</div>
<div class="linebreak">
</div>
</div>
</div>
{{/ads}}
define(['jquery', 'hgn!templates/helload','masonry'], function($, render, masonry) {
function renderAds(container) {
var $container = $(container);
// ajax call for data
$.getJSON('../JSON/ads.txt', { count: 10 })
.success(function(data) {
$(container).html(render(data));
$('#columns').masonry({ //add masonry nesting
itemSelector: '.helload',
isFitWidth: true
});
})
.error(function(err) {
alert('kaboom');
});
}
return renderAds;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment