Event "pjax:beforeApply" to update options #550
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a simple proposal to add a
pjax:beforeApply
event, which let us change the container (and some others options) according to the content returned by the AJAX request.I'm using this to load content into different containers: main page and modals. A modal is just some content displayed on top of the main page without changing the page's url. So we have a static website that looks dynamic by remotely loading modals.
I understand that it's probably not an intended usage of pjax.
Example:
Current solution: bind with different options
The current solution is to apply pjax according to an attribute:
The issue with this solution is to ensure that all links have the correct target (
data-pjax
). Also it doesn't work for submitting a form in a modal (data-pjax=modal
) that causes a redirection for the main page (the redirected content will be displayed in the modal container).