Menu icon Foundation
Saving Section state

I'm trying to save the state of a section (keep the active section open after a page reload/form submit)

I have a few different pages with sections (containing forms). I was planning to use cookies to do this but I'm unable to manually toggle the active section there doesn't seem to be a method for this.

Also the callback is called twice when changing section, this is not such a big deal it will just mean my cookie is set twice.

Also I'm not sure the best way to identify each section so that I can keep the state of multiple section of different pages.

Any suggestion would be appreciated.

sectionFoundation 4

I'm trying to save the state of a section (keep the active section open after a page reload/form submit)

I have a few different pages with sections (containing forms). I was planning to use cookies to do this but I'm unable to manually toggle the active section there doesn't seem to be a method for this.

Also the callback is called twice when changing section, this is not such a big deal it will just mean my cookie is set twice.

Also I'm not sure the best way to identify each section so that I can keep the state of multiple section of different pages.

Any suggestion would be appreciated.

Rafi Benkual almost 6 years ago

You want to use deep linking for this. http://foundation.zurb.com/docs/v/4.3.2/components/section.html

Like this
HTML
<div class="section-container auto" data-section data-options="deep_linking: true">
<section class="active">
<p class="title" data-section-title><a href="#thesection">Section 1</a></p>
<div class="content" data-slug="thesection" data-section-content>
<p>Content of section 1.</p>
</div>
</section>

Make sure the data-slug is the same name.

Michael Egan almost 6 years ago

Thanks Rafi, Sorry should have actually read the docs properly.

It's still not working but I will try and sort it out myself first.

Thanks again for you help.