I'm using JQuery to setup some comboboxes and I've wrapped the .combobox calls in the .ready function to make sure my controls are available, but on every 10th or so time loading the page, the elements used for the comboboxes are not in the DOM. What is going on and how is this possible?

My external javascript

$(document).ready(function()
{
    if (document.getElementById('selMinPrice'))
    {
        console.log('selMinPrice exists in the DOM.');
        console.log('selMinPrice value=' + document.getElementById('selMinPrice').value);
    }
    else
    {
        console.log('selMinPrice DOES NOT EXIST in the DOM!!!!!!!!!!!!!!!!!!!!!!!!!!');
    }
    // setup min & max price comboboxes
    $(".selMinPrice").combobox();
    $(".selMaxPrice").combobox();
    $("#toggle").click(function ()
    {
        $(".selMinPrice").toggle();
        $(".selMaxPrice").toggle();
    });
});

I've only noticed the problem in IE for some reason, but that's not to say it doesn't exist in the other browsers.

Thoughts?

有帮助吗?

解决方案

This is a bug that was introduced in jQuery 1.8.0, and fixed in 1.8.1

Ticket: http://bugs.jquery.com/ticket/12282

It was mentioned in the release notes for jQuery 1.8.1 at http://blog.jquery.com/2012/08/30/jquery-1-8-1-released/

Upgrading from 1.8.0 to 1.8.1 should ensure that .ready isn't being called too early in IE.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top