Skip to content

Commit

Permalink
page.js >1.5.0 support
Browse files Browse the repository at this point in the history
  • Loading branch information
kethinov committed Dec 3, 2014
1 parent 0cdd015 commit 76d44ab
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "page.js-body-parser.js",
"description": "Plugin for page.js which implements support for forms akin to body-parser.",
"author": "Eric Newport <kethinov@gmail.com>",
"version": "1.0.3",
"version": "1.0.4",
"homepage": "https://github.com/kethinov/page.js-body-parser.js",
"license": "Creative Commons Attribution 4.0 International License",
"main": "page.js-body-parser.js",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "page.js-body-parser.js",
"version": "1.0.3",
"version": "1.0.4",
"description": "Plugin for page.js which implements support for forms akin to body-parser.",
"main": "page.js-body-parser.js",
"repository": {
Expand All @@ -15,7 +15,7 @@
"homepage": "https://github.com/kethinov/page.js-body-parser.js",
"readmeFilename": "README.md",
"dependencies": {
"page": "^1.4.0"
"page": "^1.5.0"
},
"keywords": [
"page.js",
Expand Down
9 changes: 6 additions & 3 deletions page.js-body-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,14 @@
e.preventDefault();
page.show(orig, {body: body});
}

var Context = page.Context;

// overload page.js show method to add support for body parser
page.show = function(path, state, dispatch){
var ctx = new page.Context(path, state);
if (state && state.body) ctx.body = state.body;
page.show = function(path, state, dispatch) {
var ctx = new Context(path, state);
page.current = ctx.path;
if (state && state.body) ctx.body = state.body; // new
if (false !== dispatch) page.dispatch(ctx);
if (false !== ctx.handled) ctx.pushState();
return ctx;
Expand Down

0 comments on commit 76d44ab

Please sign in to comment.