javascript - Jade block extend for each item in database? -


what doing wrong?

test.jade

doctype !!! 5  html(lang="en-us")      head          title test          h1 information;      body          block testcontent          form(method="post")              input(type="button", value="refresh")

testcontent.jade

extends test    append testcontent      br      p test #{title}

routing handler;

app.get('/search', function(req, res) {                res.render('test');  });    app.post('/search', function(req, res) {        table.find().sort({created:1}).toarray(function(err, items) {           if(err) {              console.log(err);          }          else {              res.render('testcontent', {title:items._id});          }      });  });

trying make write 'test' , title each item in database. click 'refresh' in page, nothing happens.

when user sends post using refresh button, it's meant every entry's _id in database , stick in array table.find().sort({created:1}).toarray()

then wanted render testcontent each entry, res.render('testcontent', {title:items._id}); should push out several entries of "test exampletitle" on new lines.

then goes testcontent block in first file, can 'updated' every time user clicks refresh.

right?

but doesn't work, no errors thrown, doesn't add "test title" text /search route want to.

i'm using node.js/express , mongodb.

did check if form submitted? change type of button submit button , submit form. , in route handler, see passing 1 title template, see 1 line in page. if want 1 line per entry, should pass whole array template , iterate using 'each' construct in jade template


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -