I ran into the same problem yesterday, and although I would post the solution I found here. (Works in bootstrap 3x)
I also wanted to use Kaminari to split into multiple tables inside tabs in bootstrap. the problem is that every time you promote a page, it refreshes and sends you back to the first tab.
The first step necessary to solve this problem is to figure out how to direct your page to a specific tab when it loads. On some searches, I realized that I could do this by adding a hash binding to the tab to the tab url. (I can't remember where I found this.)
// Example
CoffeeScript
$ -> hash = window.location.hash hash and $("ul.nav a[href=\"" + hash + "\"]").tab("show") $(".nav-tabs a").click (e) -> $(this).tab "show" scrollmem = $("body").scrollTop() window.location.hash = @hash $("html,body").scrollTop scrollmem return return
Javascript
$(function(){ var hash = window.location.hash; hash && $('ul.nav a[href="' + hash + '"]').tab('show'); $('.nav-tabs a').click(function (e) { $(this).tab('show'); var scrollmem = $('body').scrollTop(); window.location.hash = this.hash; $('html,body').scrollTop(scrollmem); }); });
Then everything is needed to transfer the correct anchor to Kaminari.
= paginate @foo, :param_name => "page_method", :params => { :anchor => 'tab4' }
Greetings
Aaron source share