jquery - Express Js + Node JS + load .html into div and change URI -
i started utilize express.js alongside node.js , rendering engine .ejs
i load .ejs file, form of .html div on page. far quite acquainted how using jquery s' load() function, uri after using method remains same. in illustration below:
$('.about').bind('click', function(event){ event.preventdefault(); $('.container').load('about.ejs'); })
i click button, , loads div. uri remains same www.page.com/
the way have working in node.js , express.js follows:
app.get('/about', function (req, res){ res.render('about',{ title: appname, menu: "about" }); });
is there way can recreate behavior using express js changes uri mypage.com/about ?
try this.
$('.about').bind('click', function(event){ event.preventdefault(); $('.container').load('about.ejs'); history.pushstate({}, 'about', '/about'); });
be careful though. not browsers back upwards force state. there libraries, pjax, handle you.
jquery node.js express url-routing ejs
No comments:
Post a Comment