Add example
This commit is contained in:
25
example/example.js
Normal file
25
example/example.js
Normal file
@@ -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)
|
||||
})
|
||||
|
||||
15
example/index.html
Normal file
15
example/index.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<title>Hello</title>
|
||||
<script src='../pjax.js'></script>
|
||||
<script src='example.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class='body'>
|
||||
<h1>Index</h1>
|
||||
hello. Go to <a href='page2.html'>Page 2</a> and view your console to see Pjax events.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
15
example/page2.html
Normal file
15
example/page2.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<title>Hello</title>
|
||||
<script src='../pjax.js'></script>
|
||||
<script src='example.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class='body'>
|
||||
<h1>Page 2</h1>
|
||||
Hello. Go to <a href='index.html'>Index</a>.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user