Skip to content

Instantly share code, notes, and snippets.

@scopevale
Created January 25, 2012 10:48
Show Gist options
  • Save scopevale/1675793 to your computer and use it in GitHub Desktop.
Save scopevale/1675793 to your computer and use it in GitHub Desktop.
jsFiddle demo - $.getJSON & jQuery template demo
body {
font: normal 11px auto "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
color: #4f6b72;
background: #E6EAE9;
}
a {
color: #c75f3e;
}
#mytable {
width: 700px;
padding: 0;
margin: 0;
}
caption {
padding: 0 0 5px 0;
width: 700px;
font: italic 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
text-align: right;
}
th {
font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
color: #4f6b72;
border-right: 1px solid #C1DAD7;
border-bottom: 1px solid #C1DAD7;
border-top: 1px solid #C1DAD7;
letter-spacing: 2px;
text-transform: uppercase;
text-align: left;
padding: 6px 6px 6px 12px;
background: #CAE8EA url(images/bg_header.jpg) no-repeat;
}
th.nobg {
border-top: 0;
border-left: 0;
border-right: 1px solid #C1DAD7;
background: none;
}
td {
border-right: 1px solid #C1DAD7;
border-bottom: 1px solid #C1DAD7;
background: #fff;
padding: 6px 6px 6px 12px;
color: #4f6b72;
}
td.alt {
background: #F5FAFA;
color: #797268;
}
th.spec {
border-left: 1px solid #C1DAD7;
border-top: 0;
background: #fff url(images/bullet1.gif) no-repeat;
font: bold 10px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
}
th.specalt {
border-left: 1px solid #C1DAD7;
border-top: 0;
background: #f5fafa url(images/bullet2.gif) no-repeat;
font: bold 10px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
color: #797268;
}
<script id="template" type="text/x-jquery-tmpl">
<tr>
<td>${display_name}</td>
<td>${shift_date}</td>
<td>${task_name}</td>
<td>${start_time_ap}</td>
<td>${end_time_ap}</td>
<td>${status}</td>
</tr>
</script>
<h2>CAS Shifts Summary Report</h2>
<table id="report">
<tr>
<th>Display Name</th>
<th>Shift Date</th>
<th>Task Name</th>
<th>Start Time</th>
<th>End Time</th>
<th>Status</th>
</tr>
</table>
var url = 'https://api.mongolab.com/api/1/databases/wps_demo/collections/CAS_shifts?view=json&apiKey=4f192e7de4b0aaf4187281a8';
$.getJSON(url, function(theShifts) {
$("#template").tmpl(theShifts).appendTo("#report");
});
name: GJSRequest.HTML - jsFiddle/Gist integration demo
description: jsFiddle demo hosted on Gist using HTML Request to get Ajax data
authors:
- Gary Smith
title:
- JS Fiddle - jsFiddle/Gist integration demo - students
resources:
- http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.js
normalize_css: no
...
@scopevale
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment