Drop down option menu using onsen UI

jalpa picture jalpa · Nov 25, 2014 · Viewed 10.7k times · Source

I want to develop drop down menu header as available in android navigation toolbar. I am using phonegap & onsen UI Framework to develop mobile application. I can able to load sliding menu from left & right side but right now my requirement is to open drop down if one should press icon display in image.

Same list should be displayed(open) if user press option button from phone device. I am not using jquery or jquery mobile to develop mobile UI. I don't want to develop drop down menu using html5 & css, so I request you please let me know some alternative way to handle it.

Answer

Andreas Argelius picture Andreas Argelius · Nov 26, 2014

You could try using <ons-popover> with an <ons-list> inside.

Create the popover inside a template:

<ons-template id="popover.html>
  <ons-popover direction="down" cancelable>
    <ons-list>
      <ons-list-item modifier="tappable">Option 1</ons-list-item>
      ...
    </ons-list>
  </ons-popover>
</ons-template>

You can show the popover using the following JavaScript code:

ons.createPopover('popover.html').then(function(popover) {
  popover.show();
});

I've created an example that shows how you can use it as a dropdown menu: http://codepen.io/argelius/pen/zxGEza