开发者

appendTo and other dom manipulators problems in IE7/IE8

开发者 https://www.devze.com 2022-12-29 07:02 出处:网络
I\'ve a strange behaviour with jquery ui autocomplete and IE7/8. The de开发者_StackOverflowfault behaviour of autocomplete is to create a UL and append it to the BODY of the page. In my case i want to

I've a strange behaviour with jquery ui autocomplete and IE7/8. The de开发者_StackOverflowfault behaviour of autocomplete is to create a UL and append it to the BODY of the page. In my case i want to append this UL to the DIV that also has the INPUT (where the autocomplete is triggered). So i've done this:

(function($) {
  $.widget("ui.combobox", {
                _create: function() {
                var select = this.element.hide();
                var outerDiv = $("<div>")
                               .insertAfter(select);
                //Autocomplete code...
                .
                .
                $('body').children('ul.ui-autocomplete').appendTo(outerDiv);
            }
        });
})(jQuery);

This works fine on Firefox/Chrome, but IE7/8 doesn't append the UL to to the outerDiv, it just lets the UL appended to the BODY of the page. I solved my problem, by actually passing the

$('body').children('ul.ui-autocomplete').appendTo(outerDiv);

to the outside of the function, but i would like to do it in a more elegant way :-)

Thanks in advance.

0

精彩评论

暂无评论...
验证码 换一张
取 消