Web Designing, Web Development, Website Design, Website Development, SEO

0091 98233 72069

COGS: CUSTOMISED, OPTIMISED, GENERALISED WEB DESIGN & WEB DEVELOPMENT SOLUTIONS

jquery autocomplete wrong position

jQuery autocomplete is very good tool. It works very well. The autocomplete drop down shows below textbox. But I faced issue when a fixed width assigned to body.
I fixed width of body in stylesheet as body{width:900px;} and it created issue for autocomplete. Autocomplete drop down has been placed some where else from the targetted text box.
To solve the problem I implemented following solution and it is working fine.

Edit jquery.autocomplete.js file.

find following code
show: function() {
var offset = $(input).offset();

this code is at around 702 line number

Add following code just below the code you found

var screenWidth = screen.width;
var bodyWidth = $(“body”).width();
if (screenWidth > bodyWidth)
{
var diff = (screenWidth – bodyWidth)/2;
offset.left = offset.left – diff;
}

With this code now jquery autocomplete drop down positioned horizontally properly even if width of the body is fixed. With 100% width there is no problem .