Skip to content

Repository files navigation

Pagelets

Upgrading from v1 to v2

Usage

Initialize

Initialize pagelet events (link clicks and form submissions)

Pagelets.init(options);

Options

PropertyTypeDefaultDescription
selectorstringa[data-uri],button[data-uri],[href][data-target]Which "click" event elements to react to
formSelectorstringform[data-uri],form[data-target]Which "submit" event elements to react to
defaultTargetstringdocument.bodyIf no data-target specified, which container to load the content into
allowPersistentTargetsbooleantrueIf a page has been reloaded, allow pagelets to load into containers of the same name
listenElementNodedocumentListen to links within this container only
minRefreshRateint500Minimum time to wait between pagelet refreshes
iteratorActionIteratornew ActionIterator()set the default iterator

Manual request

Manually make pagelet request

constreq=newPagelets.Request(options);Pagelets.load(req).then(({request, response})=>{// process response (if necessary)}).catch((e)=>{// error handling});

Pagelet Options

PropertyTypeDefaultDescription
url [required]StringURL of the resource to request
iteratorActionIteratoruses global optionsaction iterator to use when processing the response
sourceElementElementelement requesting the pagelet
targetElementElement/Stringelement to receive the default pagelet content
pushUrlStringURL to set in the address bar
headersObjectobject containing custom headers for the request
dataObjectobject containing post data
methodStringrequest method to use
withCredentialsBooleanfalseset withCredentials

About

PJAX library for loading content into pages over XHR

Resources

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages