views:

18

answers:

0

I've got some jQuery code in my page for a City AutoComplete. The problem I'm running into is that it works fine in FireFox but I only get the "waiting icon" in IE8.

I've been pounding away at this for about 3 hours without any luck. I've even tried swapping out the AutoComplete for a different library, but I just can't seem to get it to work in IE. Any help would be appreciated.

  <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"&gt;&lt;/script&gt;
  <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"&gt;&lt;/script&gt;
<script language="javascript" type="text/javascript">

                $(function () {
                    $.expr[':'].textEquals = function (a, i, m) {
                        return $(a).text().match("^" + m[3] + "$");
                    };



                    $('#<%= txtForSaleCity.ClientID %>').autocomplete({
                        source: '<%= Page.ResolveClientUrl("~/RegionsAutoComplete.axd")%>?PID=<%= hiddenForSaleProvince.value %>',
                        change: function (event, ui) {
                            //if the value of the textbox does not match a suggestion, clear its value
                            if ($(".ui-autocomplete li:textEquals('" + $(this).val() + "')").size() == 0) {
                                $(this).val('');
                            }
                            else {
                                $('#<%= hiddenForSaleCityID.ClientID %>').val(ui.item.id);
                            }
                        }
                    }).live('keydown', function (e) {
                        var keyCode = e.keyCode || e.which;
                        //if TAB or RETURN is pressed and the text in the textbox does not match a suggestion, set the value of the textbox to the text of the first suggestion
                        if ((keyCode == 9 || keyCode == 13) && ($(".ui-autocomplete li:textEquals('" + $(this).val() + "')").size() == 0)) {
                            $(this).val($(".ui-autocomplete li:visible:first").text());
                        }
                    });



                    $('#<%= txtWantedCity.ClientID %>').autocomplete({
                        source: '<%= Page.ResolveClientUrl("~/RegionsAutoComplete.axd")%>?PID=<%= hiddenWantedProvince.value %>',
                        change: function (event, ui) {
                            //if the value of the textbox does not match a suggestion, clear its value
                            if ($(".ui-autocomplete li:textEquals('" + $(this).val() + "')").size() == 0) {
                                $(this).val('');
                            }
                            else {
                                $('#<%= hiddenWantedCityID.ClientID %>').val(ui.item.id);
                            }
                        }
                    }).live('keydown', function (e) {
                        var keyCode = e.keyCode || e.which;
                        //if TAB or RETURN is pressed and the text in the textbox does not match a suggestion, set the value of the textbox to the text of the first suggestion
                        if ((keyCode == 9 || keyCode == 13) && ($(".ui-autocomplete li:textEquals('" + $(this).val() + "')").size() == 0)) {
                            $(this).val($(".ui-autocomplete li:visible:first").text());
                        }
                    });
                });
</script>

Here's the staging link.
http://staging.infinitas.ws/business-trader.com/Search/ForSale.aspx

To reproduce, just select a COUNTRY then an PROVINCE. The system will then wire up the autocomplete for a CITY.