Express middleware for handling Pjax requests that works with Express version 3 (and higher).
npm install --from-git git://github.com/optikfluffel/express-pjax.git
If you use res.renderPjax
method, the request of pjax will be handled automatically if you put your views without the extends layout
stuff in a pjax
subfolder and include them in your layout enabled views with include pjax/foo
. See comment from @kwood1138 or my express-pjax-demo for more details.
var express = require('express');
var pjax = require('express-pjax');
var app = express.createServer();
app.configure(function() {
app.use(pjax());
// -- snip --
});
app.get('/', function(req, res) {
res.renderPjax('index', { locals: { hello: "Hello World!" } });
});
app.get('/foo', function(req, res) {
res.renderPjax('foo');
});
You can find a demo using this thing together with jquery-pjax over at github.com/optikfluffel/express-pjax-demo
- Support redirect.
Thanks go to @kwood1138 for this little solution. I just put it in a github repo to use it with npm.
DO WHATEVER THE FUCK YOU WANT, PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHATEVER THE FUCK YOU WANT.