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

[Proposal] Pjax as EventEmitter? #53

Open
darylteo opened this issue Jan 5, 2016 · 7 comments
Open

[Proposal] Pjax as EventEmitter? #53

darylteo opened this issue Jan 5, 2016 · 7 comments
Milestone

Comments

@darylteo
Copy link
Collaborator

darylteo commented Jan 5, 2016

At the moment, events are emitted via document using native dispatchEvent.

This (I think) causes issues if multiple instances of pjax are used.

Better to have Pjax as a EventEmitter emit its own events. This does increase the size of the library (4-5kb?).

@MoOx
Copy link
Owner

MoOx commented Jan 5, 2016

Good idea.

@BehindTheMath
Copy link
Collaborator

I think this will make testing easier and cleaner, as it will be easier to remove event listeners and avoid issues of event listeners on document carrying over between tests.

@thewatts
Copy link
Contributor

Oddly enough, I ran into this issue tonight.

I'm using multiple pjax instances to load in different URLs // selectors.

Once both are used, one stops working (events never fired, switches never fired, etc).

Sending in custom options via loadUrl isn't working either.

Is there a workaround for this?

@BehindTheMath
Copy link
Collaborator

Why do you need multiple instances?

@thewatts
Copy link
Contributor

@BehindTheMath I have one instance that loads in urls with specific selectors (main content), and another that's being used with a realtime filter (updates the filter's content, filter results)

@BehindTheMath
Copy link
Collaborator

It's a bit hard to picture without seeing it, but Pjax is only meant to be used with links and submitting forms, not for filtering data.

@thewatts
Copy link
Contributor

Pjax is only meant to be used with links and submitting forms, not for filtering data.

I'm using pjax to click a link, and selectively fetch the content from the URL - nothing different than what's detailed in the README, etc.

I just happen to be using multiple pjax instances :)


The issue itself is really hard to reproduce - so I'll table it for now. Just wasn't sure if there was a recommended way of handling the scenario of needing multiple instances.

Thanks!

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

No branches or pull requests

4 participants