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

With Js enabled there are multiple calls fired on each click #36

Open
dej611 opened this issue Mar 29, 2015 · 1 comment
Open

With Js enabled there are multiple calls fired on each click #36

dej611 opened this issue Mar 29, 2015 · 1 comment

Comments

@dej611
Copy link
Contributor

dej611 commented Mar 29, 2015

When the JS option is enabled (always by default) a script tag is appended in the DOM (as for this line here).

This behavior raises two different issues:

  • having the assets pipeline on (as recommended in production) the server will reply with an HTML 404 as the script should really be compiled with the others
  • If the script is served, it will load and bind to the link on the pagination bar an AJAX function.

This leads to this kind of behaviour:
screen shot 2015-03-29 at 17 41 44
Note: this is trigger by a single click, as you see the starting point is the same of all 4.

When the user clicks a couple of letters on the bar a massive number of requests start to hit the server.

While there are some solutions to fix such behavior it looks to me that this kind of things should really be implemented by the user himself rather than be in the bundle.

For instance a similar gem such will_paginate works this way - no AJAX support in the bundle - and adapt it to work with AJAX is not that hard: http://asciicasts.com/episodes/174-pagination-with-ajax

I'd propose to remove such option, or at least ship the JS file as a separate asset that can be included but no automagically included as it does right now.
Documenting on the WIKI how to enable it seems a reasonable solution to me and will make also the support of this gem much simpler.

@lingz
Copy link
Owner

lingz commented May 16, 2015

My only concern here is A) it would break backwards compatibility, and B) it does add some complexity in requiring another step.

Perhaps we could make it so the script tag is served outside the boundary of the reloaded html.

A current situation exists in that the dev can turn off js in the options parameter and implement the functionality themselves.

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