Disable tab in zurb foundation - zurb-foundation

I'm using Zurb Foundation and have the following html:
<div class="section-container auto" data-section>
<section>
<p class="title" data-section-title>Tab 1</p>
<div class="content" data-section-content>
<p>Content of section 1.</p>
</div>
</section>
<section>
<p class="title" data-section-title>Tab 2</p>
<div class="content" data-section-content>
<p>Content of section 2.</p>
</div>
</section>
</div>
Is it posible to disable second tab? Tab button should be visble, but not clickable.

You could add some CSS to disable it.
.disabled {
pointer-events: none;
cursor: default;
}
Edit
With respect to Dolondro's comment and pointer events not working in IE, see css 'pointer-events' property alternative for IE

slightly dirty hack, but it will work everywhere (don't forget to add class 'disabled' to the tag)
$("[data-tabs] > li.disabled a").bind("click", function(e)
{
e.preventDefault();
e.stopImmediatePropagation();
e.stopPropagation();
});

You can set a custom link class to only consider enabled tabs via data-link-class and then use the specified class only the enabled tabs.
<ul class="tabs" data-tabs data-link-class="enabled" id="disabled-tabs">
<li class="enabled"><a>Tab 1</a></li>
<li><a>Tab 2</a></li>
</ul>
By default, foundation uses tabs-title for the link class, but you can override it. In this example, I'm using enabled to only target enabled tabs. Foundation will ignore the tabs without the enabled class.
You'll probably also want to disable pointer events on the disabled tabs so that the user doesn't think they can interact with the disabled tab.
.tabs li:not(.enabled) a {
pointer-events: none;
}

Related

Zurb Foundation Accordion not expanding

I am using Foundation 6.7.4.
I am trying to set up an accordion like the one in their example here https://get.foundation/sites/docs/accordion.html
I have my accordion set up as such:
<div class="grid-x">
<div class="medium-12 cell">
<ul class="no-bullet accordion" data-accordion data-allow-all-closed="true" data-multi-expand="true">
<li class="accordion-item" data-accordion-item>
<a href="#" class="accordion-title">
My Title
</a>
<div class="accordion-content" data-tab-content>
My content
</div>
</li>
</ul>
</div>
</div>
When I click the A tag I can see the Accordion expand for a fraction of a second before closing. I can also see the CSS classes and attributes change in the inpector.
But I'm unsure why none of these are sticking and what's causing the accordion to revert its's self.
Would anyone know why?
Turned out this was because I had 2 foundation.js files referenced.

How to call a django url after clicking on a bootstrap tab and show results on the tab content?

I have created two bootstrap tabs whose data is comming from django functions. I can easily post essential data of all tabs while the tabs are loaded but I want to load data of each tab once the tab is clicked instead of loading all data together.
Bootstrap uses href or data-target to load a tab content. So, when I set django url in href attribute and activate the tab by JavaScript, the django function is invoked but bootstrap does not open the tab. It always opens the first tab.
<ul id="myTab" class="nav nav-tabs bar_tabs" role="tablist">
<li role="presentation" class="active">Profile
</li>
<li role="presentation" class="">Monitor
</li>
</ul>
<div id="myTabContent" class="tab-content">
<div role="tabpanel" class="tab-pane fade active in" id="tab_content1" aria-labelledby="home-tab">
</div>
<div role="tabpanel" class="tab-pane fade" id="tab_content3" name="tab_content3" aria-labelledby="profile-tab">
{% include "setting/monitor.html" %}
</div>
</div>
My JavaScript code is:
<script>
$(document).ready(function(){
switch("{{section}}"){
case 'monitor':
$('#myTabContent #tab_content3').tab('show');
break;
case 'profile':
$('#myTab a[href="#tab_content1"]').click();
break;
}
})
</script>
I have also used the below javascript to activate second tab, but it does not wok.
$("#myTab").tabs("select", 2);
I appreciate your help.
Bootstrap will show the tab which you marked as "active". So when returning the HTML for 2nd tab make that tab as active by adding class="active" attribute to it.
May be you need to pass that information from view in the context and add that class to appropriate tab in the template.

Zurb foundation 6.4.3 6.4 topbar menu classes expanded menu-centered not working

For testing, I cloned a site that I built with Foundation 6.3.1 to another folder where I have 6.4.3 installed. Everything seems to display properly, I'm using the float mode.
Anyway, in 6.3.1 I used a couple of classes to style my topbar: expanded and menu-centered.
I was reading in the docs, from what I understand, you have to include #menu-expand; and #menu-align;.
Anyway, I tried this and 6.4.3 still just blows out my topbar.
I've posted 2 links here, both have the same HTML and CSS code for comparison.
See this version first - be sure to shrink your browser until you see the mobile menu and click it as well.
 Foundation 6.3.1 Version on CodePen  (works fine)
<!-- html -->
<div class="row top-row-wrapper">
<div class="top-bar menu-centered"> <!-- menu-centered -->
<div class="title-bar" data-responsive-toggle="my-menu" data-hide-for="medium">
<button class="menu-icon center" type="button" data-toggle="my-menu" data-responsive-toggle="my-menu"></button>
<div class="title-bar-title menu-left">MENU</div>
</div>
</div>
<div class="top-bar" id="my-menu">
<div class="top-bar-right">
<ul class="menu expanded menu-centered" data-responsive-menu="drilldown medium-dropdown">
<li><a class="home-link" href="/">HOME</a></li>
<li>SIRES</li>
<li>DONORS</li>
<li>BULLS</li>
<li>HEIFERS</li>
<li>BULL CARE</li>
<li>CONTACT</li>
</ul>
</div>
</div>
</div>
/*SCSS*/
$menu-margin: 0rem;
$menu-margin-nested: 1rem;
$menu-item-padding: 1rem;
$menu-icon-spacing: 1.25rem;
$topbar-padding: 0;
$topbar-title-spacing: 0rem 1rem 0rem 0;
$topbar-input-width: 200px;
$topbar-unstack-breakpoint: medium;
.top-bar ul.menu li {
padding-left:.5em;
padding-right:.5em;
}
.top-bar ul.menu li a {
border:1px solid blue;
}
.top-bar-right ul.menu li {
white-space:nowrap;
}
Foundation 6.4.3 Version on CodePen (same code, but notice expanded and menu-centered fail to work and the mobile menu goes bonkers). How to make the 6.4.3 version functional like the 6.3.1 version?
On a side note: I love testing out little snippets on Codepen, however, I can't figure out if it is possible to add / modify the app.scss that it uses in order to add do things like comment out includes (such as foundation-flex-grid / or add includes such as #include menu-expand;.

Foundation Responsive Toggle Dropdown Nav that is Sticky

I'm new to Foundation and I'm trying to mix several components of Foundation into one nav bar just by using their classes and data attributes they've provided and demoed in their html.
I followed instructions for Responsive Toggle Dropdown at: http://foundation.zurb.com/sites/docs/responsive-navigation.html
And I want to make that Sticky. See: http://foundation.zurb.com/sites/docs/sticky.html#sticky-navigation , 'Creating a sticky Nav Menu with Title Bar, DropdownMenu, and Sticky!'
They left out the toggle part so I don't know if this is even feasible by using just the classes and data attributes they provide for the html.
I can get them both to work separately but not together. It seems buggy but it could be me. I'd love to hear from anyone out there who might have succeeded in doing this!
This is what I have so far. The wider window is sticky and responsive. The dropdown initially falls behind the jumbotron until you scroll up a bit.
The narrow window's responsive toggle works but the sticky does not. And initially the dropdown falls beneath the jumbotron until you widen the window a bit. The drilldown works fine.
This is the code:
<div class="row">
<div data-sticky-container>
<div class="top-bar" data-responsive-toggle="main-menu" data-hide-for="medium" data-sticky data-options="marginTop:0;" style="width:100%" data-top-anchor="1">
<button class="menu-icon" type="button" data-toggle></button>
<div class="top-bar-title">Fruit Is Good</div>
</div>
</div>
<div data-sticky-container>
<nav class="top-bar" id="main-menu" data-sticky data-options="marginTop:0;" style="width:100%" >
<div class="top-bar-left">
<ul class="vertical medium-horizontal menu" data-responsive-menu="drilldown medium-dropdown" style="width: 300px;">
<li class="menu-text">Fruit Is Good</li>
<li class="active">Home</li>
<li>Apples</li>
<li>Citrus
<ul class="vertical menu">
<li>Oranges</li>
<li>Limes</li>
<li>Lemons</li>
</ul>
</li>
<li>Bananas</li>
<li>Gallery</li>
</ul>
</div>
</nav>
</div>
</div>
And you can find the demo here: http://lucillekenney-demos.com/fruit/home.html

Foundation 6 Off Canvas, where should I put the menu content?

I'm following Foundation 6 documentation to create an off canvas menu : http://foundation.zurb.com/sites/docs/off-canvas.html
Here is what I did :
<body>
<div class="off-canvas-wrapper">
<div class="off-canvas-wrapper-inner" data-off-canvas-wrapper>
<div class="off-canvas position-left" id="offCanvasLeft" data-off-canvas>
<ul class="vertical menu">
<li>test1</li>
<li>test2</li>
<li>test3</li>
<li>test4</li>
</ul>
</div>
<div class="off-canvas position-right" id="offCanvasRight" data-off-canvas
data-position="right"></div>
<div class="off-canvas-content" data-off-canvas-content>
<div class="title-bar">
<div class="title-bar-left">
<button class="menu-icon" type="button" data-toggle="offCanvasLeft"></button>
<span class="title-bar-title">Zurb</span>
</div>
<div class="title-bar-right">
<button class="menu-icon" type="button" data-toggle="offCanvasRight"></button>
</div>
</div>
</div>
</div>
</div>
</body>
But when I open the menu, here is what I get :
I can scroll it and see my test1/2/3/4, but why do I have this result?
What I want is the same as what we can see on foundation documentation when you click on 'Toggle Off-canvas'
Did I put my list in the wrong place?
I'm pretty sure my framework is up to date, and I've been following the documentation step by step, but it does not give as much informations as I would like to have
You have the menu in the right place and your example is equivalent to the examples provided in the Foundation 6 documentation.
This seems to be a bit of a design issue where the length of the Off Canvas menu is dependant on the size of the content. Because you have no content on the page, the menu is equal in height to the menu bar.
As soon as you populate off-canvas-content, the menu should appear as expected.
Click Here for a Demo.
Thank you for sharing your code. It is slightly different than the examples by ZURB for the Foundation 6 starter pages. ZURB uses "wrap" instead of "wrapper". I changed my code to match yours and voila! Their tutorial is at:
http://foundation.zurb.com/sites/docs/v/5.5.3/components/offcanvas.html
Yours:
<div class="off-canvas-wrapper">
<div class="off-canvas-wrapper-inner" data-off-canvas-wrapper>
ZURB:
<div class="off-canvas-wrap" data-offcanvas>
<div class="inner-wrap">