Change jQuery UI Autocomplete Position - Pop up, instead of down

后端 未结 4 1419
庸人自扰
庸人自扰 2020-12-08 10:23

I am placing an autocomplete box at the bottom of my page and I would like the results to pop up OVER the text box, instead of below. How can I do this?

4条回答
  •  醉话见心
    2020-12-08 10:49

    Seems as if I've been able to answer my own question already. I'm open to a better solution if someones got it. I added this to the autocomplete start up.. essentially it repositions the box on open to a new offset.

    open: function(event, ui) {
        var autocomplete = $(".ui-autocomplete");
        var oldTop = autocomplete.offset().top;
        var newTop = oldTop - autocomplete.height() - $("#quick_add").height() - 10;
    
        autocomplete.css("top", newTop);
    }
    

提交回复
热议问题