JQuery UI AutoComplete Position

前端 未结 1 1404
挽巷
挽巷 2020-12-18 22:57

I\'d like to position my autocomplete (menu) properly in relation to the browser window. That is, when the autocomplete is at the top of the page get the menu going down and

相关标签:
1条回答
  • 2020-12-18 23:24

    Use the position option to activate collision detection:

    $( "#someElement" ).autocomplete({
        source: [...]
        position: {  collision: "flip"  }
    });​
    

    DEMO

    The autocomplete uses the jQuery UI Position utility to easily place the menu relatively to the input element.

    The option collision to automatically move the element to an alternative position in case the element would not be viewable in the default direction in the viewport.

    The value flip will show the menu below or above, in the direction is will be fully viewable.

    0 讨论(0)
提交回复
热议问题