ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

Tabs do not work inside ionContent

Open gnomeontherun opened this issue 12 years ago • 10 comments

I'm not sure if this is by design or not, but if you use <ion-tabs> inside of <ion-content> the tabs will render initially but not be able to switch between tabs. Removing the <ion-content> directive makes the tabs functional. Also, the tabs do not pick up the existing ionNavBar and add padding, so I have to apply CSS.

Example: http://codepen.io/gnomeontherun/pen/oluLx?editors=101

gnomeontherun avatar Mar 31 '14 15:03 gnomeontherun

Hi @gnomeontherun - your codepen seems to work as intended? Did you forget to save something?

ajoslin avatar Mar 31 '14 15:03 ajoslin

@ajoslin I must have accidentally saved it after removing the ion-content directive, I put it back and saved.

gnomeontherun avatar Mar 31 '14 16:03 gnomeontherun

Still not working in beta.2 - not sure about this.

What's your use case?

ajoslin avatar Apr 29 '14 21:04 ajoslin

I came into this when I was trying to build out a view that had tabs and just used the ion-content directive to wrap the view. It doesn't appear to be needed, but at the least if they are not compatible then the docs should probably mention that.

gnomeontherun avatar Apr 30 '14 16:04 gnomeontherun

The problem is because <ion-content> creates an inner div, which the content is placed in, that does not have any height by default.

So the tab items, which have bottom: 0; css, end up going at the bottom of their parent element. Which in this case is the very top of the screen.

I'll add a note to the docs.

ajoslin avatar May 02 '14 18:05 ajoslin

Some news?

Why is the issue closed?

danicomas avatar Nov 27 '14 12:11 danicomas

I use it with ion-pane instead ion-content (solved). But now ion-tab pane needs margin-top: 50px because I don't see the tab content. I opened a new issue: https://github.com/driftyco/ionic/issues/2629

danicomas avatar Nov 27 '14 13:11 danicomas

Hi ! I had the same problem, I fixed it like this.

<ion-view view-title="Tabs">
    <ion-pane>
        <ion-tabs class="tabs-top">

            <!-- Tab 1 -->
            <ion-tab title="Tab 1" href="#/tab/tab1">
                <ion-nav-view name="tab-tab1">
                    <ion-content>
                        Tab 1 content
                    </ion-content>

                </ion-nav-view>
            </ion-tab>


            <!-- Tab 2 -->
            <ion-tab title="Tab 1" href="#/tab/tab2">
                <ion-nav-view name="tab-tab2">
                    <ion-content>
                        Tab 2 content
                    </ion-content>
                </ion-nav-view>
            </ion-tab>
        </ion-tabs>

    </ion-pane>
</ion-view>

gregoiremotot avatar Jul 19 '15 22:07 gregoiremotot

thanks @gregoiremotot :+1: it's worked for me!

celso-wo avatar Nov 08 '15 18:11 celso-wo

Hi

I added a div below the ion-content

<ion-view title="Tabs"> <ion-content> <div class="list" style="margin-top:28px;"> &nbsp; </div> Will this solve the problem

webantz avatar Jan 28 '16 11:01 webantz