Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding more events, preventing unload on condition #42

Closed
georgehristov opened this issue Oct 18, 2019 · 4 comments
Closed

Adding more events, preventing unload on condition #42

georgehristov opened this issue Oct 18, 2019 · 4 comments

Comments

@georgehristov
Copy link

Have you considered adding more events to the list (as in defunkt/jquery-pjax)?
Is there a way to prevent request in case some conditions not met? For instance a dirty form not saved.

@falsandtru
Copy link
Owner

Probably you should call event.preventDefault().

@georgehristov
Copy link
Author

Tried it put it did not work as expected.
And in any case it is better for have the pjax:click and pjax:clicked events to prevent even sending the request to the server

@falsandtru
Copy link
Owner

I don't provide such events. You have to call that method to disable events in capture phase. This pjax ignores disabled events. I designed event canceling in this way.

@falsandtru
Copy link
Owner

falsandtru commented Oct 18, 2019

However, anyway there is no way to prevent browser back/forward without handling beforeunload events. And since pjax usually disables browser functions to keep form data, I don't use pjax with form pages and I recommend that pjax users do so.

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

No branches or pull requests

2 participants