jquerycssjquery-uijquery-ui-menu

Is there a way to force a jQuery UI menu submenu to always position up instead of down?


I have a simple jQuery UI menu with a header bar over the top:

<div style="width: 100%; min-height: 100px;"></div>
<ul id="menu" style="width: 100px;">
  <li><a href="#">Item 1</a></li>
  <li><a href="#">Item 2</a></li>
  <li><a href="#">Item 3</a>
    <ul>
      <li><a href="#">Item 3-1</a></li>
      <li><a href="#">Item 3-2</a></li>
      <li><a href="#">Item 3-3</a></li>
      <li><a href="#">Item 3-4</a></li>
      <li><a href="#">Item 3-5</a></li>
    </ul>
  </li>
  <li><a href="#">Item 4</a></li>
  <li><a href="#">Item 5</a></li>
</ul>

<script type="text/javascript">
    $(document).ready(function(){
        $("#menu").menu();
    });
</script>

Fiddle here: http://jsfiddle.net/uW44Y/

Is there a way I can force the submenu from Item 3 to always open up from it's heading instead of down?

menu


Solution

  • The jQuery UI menu API supports a position attribute: http://api.jqueryui.com/menu/#option-position. Try something like $("#menu").menu({position: {my: 'left bottom', at: 'top right'}});