Drop down option menu using onsen UI

后端 未结 2 1320
执念已碎
执念已碎 2021-01-12 15:52

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

相关标签:
2条回答
  • 2021-01-12 16:19

    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

    0 讨论(0)
  • 2021-01-12 16:36

    Did you mean something like that?

    DEMO

    html

    <ons-modal var="modal">
       <ons-list>
    
            <ons-list-header>Browsers</ons-list-header>
    
            <ons-list-item modifier="tappable">
              <label class="radio-button radio-button--list-item">
                <input type="radio" name="a" checked="checked">
                <div class="radio-button__checkmark radio-button--list-item__checkmark"></div>
                Chrome
              </label>
            </ons-list-item>
    
            <ons-list-item modifier="tappable">
              <label class="radio-button radio-button--list-item">
                <input type="radio" name="a">
                <div class="radio-button__checkmark radio-button--list-item__checkmark"></div>
                Safari
              </label>
            </ons-list-item>
    
            <ons-list-item modifier="tappable">
              <label class="radio-button radio-button--list-item">
                <input type="radio" name="a">
                <div class="radio-button__checkmark radio-button--list-item__checkmark"></div>
                Internet Explorer
              </label>
            </ons-list-item>
    
            <ons-list-item modifier="tappable">
              <label class="radio-button radio-button--list-item">
                <input type="radio" name="a">
                <div class="radio-button__checkmark radio-button--list-item__checkmark"></div>
                Opera
              </label>
            </ons-list-item>
    
            <ons-list-item modifier="tappable">
              <label class="radio-button radio-button--list-item">
                <input type="radio" name="a">
                <div class="radio-button__checkmark radio-button--list-item__checkmark"></div>
                Firefox
              </label>
            </ons-list-item>
          </ons-list>
    </ons-modal>
    
    <ons-navigator>
      <ons-page id="my-page">
    <ons-toolbar>
            <div class="center">Toolbars</div>
            <div class="right">
              <ons-toolbar-button id="show-modal">
                <ons-icon icon="ion-ios7-plus" style="font-size: 32px; width: 1em"> 
              </ons-toolbar-button>
            </div>
          </ons-toolbar>
      </ons-page>
    </ons-navigator>
    

    javascript

    ons.bootstrap();
    
    $(document.body).on("pageinit", '#my-page', function() {
      $("#show-modal", this).click(function() {
        modal.show();
      });
    });
    
    0 讨论(0)
提交回复
热议问题