Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
135
rated 0 times [  141] [ 6]  / answers: 1 / hits: 18184  / 9 Years ago, sun, march 8, 2015, 12:00:00

How do I create a Jade page that has two buttons where each one of them redirects to another page made with Jade?


More From » node.js

 Answers
47

This is the code I made for your question:



server.js



var express = require('express');
var path = require('path');

var app = express();

app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');

app.get('/', function(req, res){
res.render('layout', {
title: 'Home'
});
});

app.get('/newpage', function(req, res){
res.render('anotherpage', {
title: 'Home'
});
});
app.listen(3000);


page1.jade



doctype html
html
head
title= title
body
p hi there!
button(onclick=move()) newPage
script.
function move() {
window.location.href = '/newpage'
}


anotherpage.jade



doctype html
html
head
title= title
body
p welcome to the other page!


Enjoy, because it took me 15 minutes to write all this and the post.



Luca


[#67528] Thursday, March 5, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cherish

Total Points: 734
Total Questions: 94
Total Answers: 86

Location: Senegal
Member since Fri, Aug 21, 2020
4 Years ago
;