1

I have a bootstrap accordion in my web app using the code found in the bootstrap documentation:

<div class="accordion" id="accordion2">
  <div class="accordion-group">
    <div class="accordion-heading">
      <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">Section 1</a>
    </div>
    <div id="collapseOne" class="accordion-body collapse in">
      <div class="accordion-inner">
      </div>
    </div>
  </div>
  <div class="accordion-group">
    <div class="accordion-heading">
      <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo">Section 2</a>
    </div>
    <div id="collapseTwo" class="accordion-body collapse">
      <div class="accordion-inner">
      </div>
    </div>
  </div>
</div>

In my application.html.erb file I have a line of code set to refresh the page every 30 seconds.

<meta http-equiv="refresh" content="30" >

When the page refreshes it always opens up with the first section open. Is there a way to refactor the code so when the page refreshes it will stay the way the page was before the refresh?

Reuben
  • 701
  • 1
  • 9
  • 17
  • http://stackoverflow.com/questions/14313270/jquery-ui-tabs-no-longer-supporting-cookie-now-what/14313315#14313315 – Trevor Sep 23 '13 at 22:41

2 Answers2

1

Realized the solution is pretty simple, by changing this line of code:

<div id="collapseTwo" class="accordion-body collapse">

to this:

<div id="collapseTwo" class="accordion-body collapse in">

the section will stay open when the page is refreshed

Reuben
  • 701
  • 1
  • 9
  • 17
0

There is, but it will be complex. The complexity lies in retaining the page state the user has created during their interactions.

Each interaction which changes the state of the GUI is going to need to be tracked so that, after 30 seconds, when the page refreshes it will be clear what the current state is.

In order to maintain the state through the page load you are going to have to use local storage in order to save the data that you collected during the interactions.

Implementing this feature as a whole will not be a trivial undertaking.

Travis J
  • 81,153
  • 41
  • 202
  • 273
  • The data within the page/accordion cannot be manipulated by the user. The data updates every 30 seconds to keep it fresh. I guess (what I should have clarified earlier) the problem I am running into is if the user is looking at the second accordion section and the page refreshes I want that section to stay open upon the refresh rather than it reloading with the first accordion section open – Reuben Sep 24 '13 at 00:02