Skip to content

Releases: imacrayon/alpine-ajax

v0.6.1

07 Jun 15:12
Compare
Choose a tag to compare

What's Fixed

  • Fixed a regression where elements with x-sync were being removed from the DOM if a response didn't contain a matching target. (Thanks for reporting @ma2thieu)

What's Changed

New Contributors

  • @eydun made their first contribution in #75

Full Changelog: v0.6.0...v0.6.1

v0.6.0

27 Apr 18:15
Compare
Choose a tag to compare

This update refactors a lot of the Alpine AJAX internals to make it more compact and predictable. We've shaved some code to make room for new automatic pre-fetching and optimistic UI features coming soon. We've also sorted out some edge cases and improved compatible with Alpine's reactivity features.

Breaking Change

There's a single breaking change in this release: $ajax no longer inherits options from other Alpine AJAX attributes. Mixing $ajax with attributes has been a point of confusion and code complexity, so we're simplifying how things work.

If you have an element that's mixing $ajax with attributes like this:

<div @click="$ajax('https://...')" x-target.push="my_target" x-headers="{ 'x-csrf': 'token' }">

Refactor to this:

<div @click="$ajax('https://...', { 
  target: 'my_target',
  history: 'push',
  headers: { 'x-csrf': 'token' } 
})">

The Infinite Scroll Example previously mixed x-target and $ajax to handle pagination, so if you've used that example in the past, be sure to update your code.

What's Changed

  • Polyfills for HTMLFormElement.requestSubmit and SubmitEvent.submitter have been removed since they have broad browser support.
  • $ajax emits all the same lifecycle events as x-target
  • The x-target "submit" and "click" events are delegated to event listeners on the window.document. These global listeners can be toggled by calling Alpine.ajax.stop() and Alpine.ajax.start() if you need to do that for some reason.
  • Renamed “Missing Target” Error to “TargetError”
  • Renamed “Missing ID” Error to “IDError”

Additions

  • Added x-target:dynamic for dynamically generating target IDs
  • Added x-merge:dynamic for dynamically generating a merge strategy
  • Added Alpine.ajax.stop() and Alpine.ajax.start() to globally disable/enable x-target event listeners

Fixes

  • Fixed an edge case where form controls named id would break rendering (#64)
  • Fixed URL query parameters not merging correctly when changing history state
  • x-headers now respects x-data values

Full Changelog: v0.5.1...v0.6.0

v0.5.1

07 Mar 16:36
Compare
Choose a tag to compare

This patch release fixes the autofocus algoritm so that hidden [autofocus] & [x-autofocus] elements will not be given focus.

v0.5.0

02 Mar 19:36
Compare
Choose a tag to compare

This release is focused on giving you more control over the request and rendering lifecycle of Alpine AJAX. To that end we've introduced a few new attributes and events. We've also revamped focus management to make it easier to control keyboard focus as content on the page changes. Lastly, we've made Alpine AJAX 30% smaller by decoupling our DOM morphing logic into a separate, optional, plugin.

Breaking Changes

1. x-focus removed in favor of x-autofocus

In most situations you can remove x-focus and add x-autofocus to the element what was being targeted by x-focus. In more complex situations you can listen for the new ajax:merged event and do whatever you want with focus in the event handler.

2. Decoupled Morph into a separate plugin

If your project is using x-merge="morph" install the Alpine Morph Plugin and you're good to go. Using the "morph" strategy without first installing the plugin will now throw an exception and prompt you to install the plugin. Our documentation examples have been updated to include install instructions when the Morph Plugin is required.

Additions

  • Added a global headers configuration option for customizing request headers for every request
  • Added x-headers and $ajax headers option for customizing request headers per request #49
  • Added ajax:merge and ajax:merged events for customizing and reacting to merged content #62
  • Added x-autofocus to declarative control keyboard focus after content is merged #56
  • Added x-target.nofocus modifier to disable autofocus behavior

Fixes

  • Changed the default enctype for AJAX requests to application/x-www-form-urlencoded in #61
  • Elements with autofocus will be focused after a merge #56
  • Form submissions now respect formaction and formmethod attributes #60
  • Right clicking a link won't fire an AJAX requests #59
  • History is updated before merging content so that relative URLs resolve correctly #58

Full Changelog: v0.4.3...v0.5.0

v0.4.3

13 Jan 14:35
Compare
Choose a tag to compare

Fixes an bug caused by form requests issues without a submitter (#48)

v0.4.2

11 Jan 19:35
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v0.4.1...v0.4.2

v0.4.1

03 Jan 18:00
Compare
Choose a tag to compare

Fixes x-merge when the directive is located outside of an Alpine component.

v0.4.0

18 Nov 17:48
Compare
Choose a tag to compare

What's New

New Contributors

Full Changelog: v0.3.0...v0.4.0

v0.3.0

08 Sep 16:56
Compare
Choose a tag to compare

This release cleans up some edge case bugs, adds some global configuration options, and some new x-target modifiers to handle redirect responses from your server.

Changed

  • x-target now requires an accompanying x-data or x-init, like a normal Alpine directive.
    <!-- Before -->
    <form x-target="...">
    </form>
    
    <tbody>
      <a x-target="...">
    </tbody>
    
    <!-- After -->
    <form x-init x-target="...">
    </form>
    
    <tbody x-init>
      <a x-target="...">
    </tbody>
    
    
  • x-arrange has been renamed to x-merge.
    Do a find and replace in your project: x-arrange -> x-merge.

Fixed

  • Request data is correctly added to the URL query string when issuing a GET request using $ajax().
  • Response promises are unwrapped in the browser console when using the Mock Server.
  • Removed a race condition that was causing flaky tests.

Added

  • x-target.nofollow will cause the browser window to reload when a redirect (3xx) response is encountered. More info in the Handling Redirects section.
  • You can set global configuration options when importing Alpine AJAX in your code.
  • $ajax() now accepts target or targets as an option.
  • $ajax() now accepts followRedirects to change the redirect behavior of the AJAX request, just like the x-target.nofollow modifier.
  • Source files are available in the NPM distribution now.

Full Changelog: v0.2.1...v0.3.0

v0.2.1

30 Jun 16:46
Compare
Choose a tag to compare

Fixed

  • aria-busy is properly removed from targets after new content is appended.

Improved

  • You'll see a friendly error message if you try to target an element that's not in the document. The previous message was very cryptic.

Full Changelog: v0.2.0...v0.2.1