From 1818c8e83fdd44faa0ae7a5a66307a43b086fd99 Mon Sep 17 00:00:00 2001 From: Seth Woodworth Date: Thu, 5 Jan 2012 23:28:06 -0500 Subject: [PATCH] return schools and courses to schools page --- app.js | 6 +++++- public/index.html | 14 +++++++++----- public/javascripts/main.js | 6 ++---- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/app.js b/app.js index 721d397..80a0591 100644 --- a/app.js +++ b/app.js @@ -489,7 +489,11 @@ app.get( '/schools', checkAjax, loadUser, function( req, res ) { // 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 diff --git a/public/index.html b/public/index.html index e9fbf41..6d14b37 100644 --- a/public/index.html +++ b/public/index.html @@ -123,13 +123,17 @@

Universities

diff --git a/public/javascripts/main.js b/public/javascripts/main.js index f81cd7b..73995c0 100644 --- a/public/javascripts/main.js +++ b/public/javascripts/main.js @@ -124,13 +124,11 @@ router.add('home', false, function(cb) { 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"); }); -- 2.25.1