@dweidner/ajax-fragment-element
v1.0.1
Published
A custom element to enable partial page updates via AJAX.
Downloads
3
Readme
<ajax-fragment>
A custom element to enable partial page updates via AJAX.
Examples
<ajax-fragment id="filters" target="posts">
<form method="get" data-use-ajax>
<!-- Form HTML omitted for brevity -->
</form>
</ajax-fragment>
<ajax-fragment id="posts">
<ol>
<li><!-- Post HTML omitted for brevity --></li>
<li><!-- Post HTML omitted for brevity --></li>
<li><!-- Post HTML omitted for brevity --></li>
</ol>
</ajax-fragment>- Use the
targetattribute to reference another fragment in the same document.
Installation
Choose one of the following options:
- Install via npm:
npm install @dweidner/ajax-fragment-element - Download the source manually from GitHub into your project.
- Skip this step and use the script directly via a 3rd party CDN (not recommended for production use)
Usage
Make sure you include the <script> in your project (choose one of these):
<!-- Host yourself -->
<script type="module" src="ajax-fragment-element.js"></script><!-- 3rd party CDN, not recommended for production use -->
<script type="module" src="https://www.unpkg.com/@dweidner/[email protected]"></script><!-- 3rd party CDN, not recommended for production use -->
<script type="module" src="https://esm.sh/@dweidner/[email protected]"></script>Features
- Load a partial page fragment via AJAX
- Customizable morphing strategy
