Friday, 15 April 2011

node.js - Render partial view with jade on select change -



node.js - Render partial view with jade on select change -

i need following,

i have <select> (a list of team names), when user selects team, relevant info re: team , display it.

how do in jade?

i'm trying following, (but i'm wrong obviously, don't see lot of documentation out there).

briefly, i'm doing include test.jade on main page, , res.render('test', {team: team_obj});

jade:

h1 #{team}.name h2 #{team}.homeground h3 #{team}.manager h4 #{team}.aka

nodejs:

collection.findone(query, function(err, team_obj){ res.render('test', {team: team_obj}); });

i'm getting info correctly in team_obj.

get next error when run app,

team not defined

now happening because test.jade getting rendered before feed team_obj.

questions:

1) doing right? include right way of partially rendering jade views? if yes, how create sure renders when user has selected option?

2) there partial views concept in jade i'm unaware of?

1) should utilize #{team.name}

2) can't alter team object 1 time selector changed. template rendered 1 time database result. - such functionality should handled client side javascript , ajax calls. partials in templates way share mutual pieces of templates, , done in jade via include.

i don't know you're rendering , including , when.. id utilize template variable #{team.name} have create sure template rendered team object.

node.js express jade

No comments:

Post a Comment