Skip to content

fix: keep ajax callbacks scoped to their originating modal#316

Open
dusan-maintains wants to merge 1 commit intokylefox:masterfrom
dusan-maintains:maintenance/ajax-instance-safety
Open

fix: keep ajax callbacks scoped to their originating modal#316
dusan-maintains wants to merge 1 commit intokylefox:masterfrom
dusan-maintains:maintenance/ajax-instance-safety

Conversation

@dusan-maintains
Copy link

@dusan-maintains dusan-maintains commented Feb 27, 2026

Summary

  • bind AJAX success/fail handling to the originating modal instance instead of the current top modal
  • avoid removing/hiding the wrong modal when asynchronous requests resolve out of order
  • safely no-op when the originating modal is already closed

Why

Current callbacks use getCurrent() / modals.pop(), which can target the wrong modal in race conditions (stacked modals or modal closed before AJAX resolution).

Changes

  • jquery.modal.js

Test Plan

  • trigger two AJAX modals in close succession and verify each response updates only its own instance
  • close the originating modal before AJAX completion and verify no unrelated modal is modified
  • verify normal single-AJAX-modal behavior is unchanged

Compatibility

  • no API changes
  • behavior change only in race/edge paths to preserve correct instance ownership

@dusan-maintains
Copy link
Author

Maintainer note: this change is scoped to async race/ownership paths only (no API/default changes). If useful, I can add a minimal reproducible snippet in the PR description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant