0.2.4 • Published 5 years ago
@dinoreic/pjax v0.2.4
Pjax - faster HTML pages loading
How to use?
Pjax will replace only contents of MAIN HTML tag https://www.w3schools.com/tags/tag_main.asp
Simple manual usage
Load page using Pjax
import '@dinoreic/pjax'
// regular page load
Pjax.load('/about')
// load page with no scroll and cache-control='no-cache'
Pjax.load('/about', { no_cache: true, no_scroll: true })
You will need to register document.on('click') handler to use Pjax.
Skip pjax on followin links and do location.href = target
Pjax.skip('/admin', '/login')
if you want to automaticly reload headers and a page on a different template, use unique template id meta tag
<meta name="pjax_template_id" content="foobar" />
No autoscrool to the top of the page
If target element (href link) or one of its paretns has defined one of the skiping classes, page window.scrollY will be kept.
Pjax.keep_scrool('.no-scroll', '.menu-heading', '.skill')
Execute action before pjax load and do not proceed if return is false
Pjax.before (href, opts) ->
if opts.node
if opts.node.closest('.in-popup')
Dialog.load href
return false
true
Init Pjax, + optionaly send function to execute on every page request
Pjax.init ->
Widget.bind()
Dialog.close()
ga('send', 'pageview') if window.ga;