Skip to content

Commit

Permalink
Default to body if we can't find a container.
Browse files Browse the repository at this point in the history
Duh ! The new method to figure what container we should append to to let
scrolling be handled naturaly and correctly by the browser introduced in
rc5 is cool. But what if it doesn't find anything (ie. django admin
...), let's default to body.
  • Loading branch information
jpic committed May 29, 2015
1 parent 1c12d4b commit 5f744a9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions autocomplete_light/static/autocomplete_light/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,14 @@ yourlabs.Autocomplete = function (input) {
every time the autocomplete is shown in the fixPosition method.
By default, this traverses this.input's parents to find the nearest parent
with an 'absolute' or 'fixed' position. This prevents scrolling / resizing
issues that we'd have by boldly using <body>.
with an 'absolute' or 'fixed' position. This prevents scrolling issues. If
we can't find a parent that would be correct to append to, default to
<body>.
*/
this.container = this.input.parents().filter(function() {
return ['absolute', 'fixed'].indexOf($(this).css('position')) > -1;
}).first();
if (!this.container.length) this.container = $('body');
};

/*
Expand Down

0 comments on commit 5f744a9

Please sign in to comment.