diff --git a/README.md b/README.md index 2cbd336..40db3e2 100644 --- a/README.md +++ b/README.md @@ -537,6 +537,12 @@ wrapper on each page (to avoid differences of DOM between pages) --- +## Examples + +Clone this repository and run `npm run example`, then open `http://localhost:3000/example` in your browser. + +--- + ## Contributing Work on a branch, install dev-dependencies, respect coding style & run tests before submitting a bug fix or a feature. diff --git a/example/example.js b/example/example.js new file mode 100644 index 0000000..229dc69 --- /dev/null +++ b/example/example.js @@ -0,0 +1,25 @@ +console.log('Document initialized:', window.location.href) + +document.addEventListener('pjax:send', function () { + console.log('Event: pjax:send', arguments) +}) + +document.addEventListener('pjax:complete', function () { + console.log('Event: pjax:complete', arguments) +}) + +document.addEventListener('pjax:error', function () { + console.log('Event: pjax:error', arguments) +}) + +document.addEventListener('pjax:success', function () { + console.log('Event: pjax:success', arguments) +}) + +document.addEventListener('DOMContentLoaded', function () { + var pjax = new Pjax({ + selectors: ['.body'] + }) + console.log('Pjax initialized.', pjax) +}) + diff --git a/example/index.html b/example/index.html new file mode 100644 index 0000000..806338f --- /dev/null +++ b/example/index.html @@ -0,0 +1,15 @@ + + +
+ +