javascript - changing jQuery UI Autocomplete Results Box Style -


i'm new jquery , i'm trying figure out how change style. have text box that, when typed into, sends ajax api request server characters typed in box -- return list of matching cities in world have character substring, , list displayed. here's text box looks without list: how text box looks without selected or entered

and, currently, how list displays (i entered characters 'santa '): how list shows now

and how list display (after tweaking html on live page): how want list show up

the html tweaked page from:

<ul class="ui-autocomplete ui-menu ui-widget ui-widget-content ui-corner-all" role="listbox" aria-activedescendant="ui-active-menuitem" style="z-index: 1; top: 0px; left: 0px; display: none;">...</ul> 

to:

<ul class="ui-autocomplete ui-menu ui-widget ui-widget-content ui-corner-all" role="listbox" aria-activedescendant="ui-active-menuitem" style="z-index: 1; top: 30px; left: 100px; display: none;">...</ul> 

i'm struggling use html styles tag correctly, because i'm struggling select correct element. tried these 2 style selectors no success:

<style> <!--- other styles defined above ---!>     .cities_list {         z-index: 1;         top: 30px;         left: 100px;     }     ul.ui-autocomplete.ui-menu.ui-widget.ui-widget-content.ui-corner-all {         top: 30px;         left: 100px;         z-index: 1;     } </style> 

what not understanding in terms of selection? help!

the jquery ui-autocomplete can reset it's dropdown position each time autocomplete event gets triggered overriding css.

you can set offset each time open function gets triggered:

$('.ui-autocomplete').css('top', $("ul.ui-autocomplete").cssunit('top')[0] + 30); $('.ui-autocomplete').css('left', $("ul.ui-autocomplete").cssunit('left')[0] + 100); 

see fiddle https://jsfiddle.net/t7xo8qvs/


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -