Back button doesn't work properly - compare to ajax_pagination #9

ronalchn opened this Issue Feb 24, 2013 · 12 comments

3 participants


Steps to replicate:

  • Go to
  • Click "Proceed to sample product catalog…"
  • Click "3" to go to page 3 of catalog
  • Click "About Wiselinks"
  • Click browser back button.

After clicking back, the expected behaviour is to go to page 3 of catalog. The observed behaviour is incorrect.

There are a number of edge cases associated with History.js, and I know them well. I have in fact authored my own gem for this -, so when I saw this gem, I decided to test this in your demo application. There are a number of other associated problems, which I won't detail here, but some of these cases are demonstrated by a video I made with my gem, which shows the correct behaviour.

In fact, I have thought very carefully about this problem to find a solution, because this was also a weakness with the pjax gem. The solution is in my javascript, in the scheme I used to track the changed sections, to restore it properly. I suppose this roundabout solution is required partly because of a weakness in the browser pushState API, causing it to return a popped state which is off by one, when what we want is actually the changes between the previous state, and the next state we need to move to.

In my gem, I also implemented form submission with POST. I also have a ruby API to optionally avoid rendering unused portions of the page.

If you are interested, perhaps we could work together to develop something which is correct, but also kept well-maintained. I put together almost all the code in my gem, but if we have more contributors working together on one gem, then it may make maintenance easier.


I just remembered, I wrote up a bit about this particular problem. See Robust Support for Browser History in AJAX Pagination.


Thanks for reporting. Fixed in wiselinks-0.5.3.

Also, I've looked over your gem. It is very good that you tried to find all cases in which History.js (or maybe browser history API) works not as it should work. But your solution seems too complex for me: you hardcoded using of Rails, added two jQuery libraries (besides of History.js), added image spinner, and OMG hardcoded css styles. Also you have written that you implemented form submission with Post, but isn't this already implemented with 'data-push' => true in Rails?

We can work together to make best solution that will be well-maintained and so on, but this solution should be easy to use, maintain and modify.

Thanks once more for reporting this bug.


I can only say that your fix did not fix it properly. You have not read Robust Support for Browser History in AJAX Pagination or you would know what is wrong with your "solution".


Can you tell what does not work properly now?


History jumping with nested partials.


Can you show real example of nested partials?


I don't think I am unjustified in saying that I don't want to spend the time helping you to understand the problem when:

  1. The article I have referred you to explains the situation
  2. You have quite resoundingly rejected my gem as completely flawed - and by implication useless. You have basically looked for any possible reason that it is poorly coded (hardly a balanced analysis - perhaps you just wanted to make it appear that your solution is far superior?)

So now you are trying to get me to come up with counterexamples to make it easy for you to fix, but you are too proud to spend some time reading the article I wrote on this topic?

If that was not the intention of your post, it certainly sounded like it was.

  1. I have already read your article, but I am asking you for a real example of of nested partials.
  2. I don't want to say, that my solution is far superior. I just asked you a couple of questions (why you hardcoded your gem to Rails, why do you use additional jQuery libraries and etc.) and wanted to show you that your solution is really too complex.

You have divs nested inside each other in your example application. Jumping in browser history can cause bugs.

You didn't ask them as questions. The dependency on Rails is not required for the javascript, however they are required for the rails-specific helper methods, and fiddling with the default_render method, to make it easier to render only the required partials/sections of a view, instead of the whole page. The default_render allows it to be specified implicitly (via the presence of a view file - much like Rails does for views normally). If somebody wants to use it without Rails, they can do the refactoring to isolate the Rails methods, and optionally add helper methods for other frameworks. Since I do not use those frameworks, I am not going to spend so much time making it work with a framework I am not familiar with.

The additional jQuery libraries are small, and I do not intend on replicating functionality available elsewhere. Dependency on jquery_ujs allows me to rely on that for loading from forms, and handle POST/PUT/??? methods automatically.

My design decision was to make it easy to use the gem, not necessarily to minimize gem size. While some things could be re-factored into different modules, it started as part of an application. Dependencies do not make it complex, rather it is a question of flexibility. Flexibility can be restored by using adapters. But I don't want to spend time doing something of dubious benefit - at least for my personal use.


Just a comment by a "bystander": @ronalchn I think you took @igor-alexandrov comments about your gem a bit strongly... He just aired his his opinion. No need to take it personally. And maybe there are even valuable hints on how to improve things. ;-) Oh and maybe this is a good opportunity to throw in my own gem: . Feedback welcome (however it is natured :)


@ronalchn I don't want anybody to take my opinion personally, really! We all do Open Source here and if you have something that you can share with community, then share it! There are a lot of ways to do this: fork, pull request, create issues e.t.c BUT NOT saying that "I know a lot of issues in some project, but I won't share it with anybody".

That is all, I wanted to say.

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