diff --git a/src/jquery.uls.regionfilter.js b/src/jquery.uls.regionfilter.js index ab1d6e5..9766ac1 100644 --- a/src/jquery.uls.regionfilter.js +++ b/src/jquery.uls.regionfilter.js @@ -70,7 +70,15 @@ }, show: function () { - var result, languagesByScriptGroup, scriptGroup, languages, i; + var result, languagesByScriptGroup, scriptGroup, languages, i, + $element = this.options.$target && this.options.$target.$element, + $parent = $element && $element.parent(), + $prev = $element && $element.prev(); + + if ( $element && $parent ) { + // Avoid reflows while adding new elements to the list + $element.remove(); + } if ( this.cache ) { // If the result cache is present, render the results from there. @@ -106,6 +114,15 @@ } } + if ( $element && $parent ) { + // Restore the element to where we removed it from + if ( $prev ) { + $prev.after( $element ); + } else { + $parent.append( $element ); + } + } + if ( this.options.success ) { this.options.success( this ); }