// If schools are found, loop through them gathering any courses that are
// associated with them and then render the page with that information.
sendJson(res, { 'user': user.sanitized, 'schools' : schools.map(function(school) {
- return school.sanitized;
+ var s = school.sanitized;
+ s['courses'] = Course.find( { 'school' : s._id } ).sort( 'name', '1' ).run(function( err, courses) {
+ return courses.map( function(c) { return c.sanitized; } );
+ });
+ return s
})})
} else {
// If no schools have been found, display none
<h1>Universities</h1>
</div>
<script id="schoolTmpl" type="text/x-jquery-tmpl">
- ${name}<br/>
+ <div class="school">
+ <div class="name">${name}</div>
+ <div class="desc">${description}</div>
+ <ul class="courses">
+ {{tmpl(courses) "#course"}}
+
+ </ul>
+ </div> <!-- .school -->
</script>
<script id="course" type="text/x-jquery-tmpl">
- <div class="proto school" id="PROTO_school" onclick="goPage('/school/___id__')">
- <div class=name>__name__</div>
- <div class=desc>__description__</div>
- </div>
+ <li>${dept}: ${name} (${number})</li>
</script>
<!--================================================================= -->
<div class=page id=pg_courses>
router.add('schools', function(data, cb) {
console.log(data);
$('#school_link').addClass('active');
- response = {
+ var response = {
id: 'school',
data: data.schools
}
- console.log('blanking html');
- $('#pg_schools').html('');
- console.log(data.schools);
+ //$('#pg_schools').html('');
$('#pg_schools').css('display', 'block');
$('#schoolTmpl').tmpl( data.schools ).appendTo("#pg_schools");
});