Amol
Amol

Reputation: 41

Can i add two sliding menu on left and right in same page using onsen ui

I used onsen ui to create sliding menu like flipkart. i used attribute side=left/right to open menu on left or right, But i required to different menu on left and right with same abovepage. When i used two different first menu is not working. I need to know how to add two different menu on left and right.

Upvotes: 4

Views: 897

Answers (2)

Reza
Reza

Reputation: 19893

You have to nest two different ons-sliding-menu like this:

<ons-sliding-menu
        main-page="page"
        menu-page="menu-left.html"
        side="left" ...>
</ons-sliding-menu>

<ons-template id="page">
    <ons-sliding-menu
            main-page="content.html"
            menu-page="menu-right.html"
            side="right" ...>
    </ons-sliding-menu>
</ons-template>

<ons-template id="menu-left.html"> ... </ons-template>
<ons-template id="menu-right.html"> ... </ons-template>
<ons-template id="content.html"> ... </ons-template>

Working here: http://codepen.io/onsen/pen/qHeJx

Hope it helps :)

Answer is copied from Frans Dios

Upvotes: 1

Vu Nguyen
Vu Nguyen

Reputation: 1088

It's possible by nesting it with "ons-split-view" because split-view could acts as a "left" sliding menu as well...

index.html:

<ons-split-view 
  secondary-page="leftMenu.html" 
  main-page="main.html" 
  main-page-width="70%" 
  collapse="portrait">
</ons-split-view>

<ons-template id="leftMenu.html">
  <ons-page>
    <!-- left menu page's contents -->
  </ons-page>
</ons-template>

main.html:

<ons-sliding-menu 
    var="app.menu" 
    main-page="mainPage.html" 
    menu-page="rightMenu.html" 
    max-slide-distance="200px" 
    type="reveal" 
    side="right">
</ons-sliding-menu>

<ons-template id="mainPage.html">
  <ons-page>
   <p style="text-align: center">
     <ons-button ng-click="app.menu.toggleMenu()">Toggle</ons-button>
   </p>
  </ons-page>
</ons-template>

<ons-template id="rightMenu.html">
  <ons-page>
    <!-- right menu page's contents -->
  </ons-page>
</ons-template>

Upvotes: 1

Related Questions