开发者

Jquery Autocomplete Unable to Empty Input on Internet Explorer

I´ve got a Jquery autocomplete input like the following:

$("#cities").autocomplete(regionIDs, {
                    minChars: 2,
                    width: 310,                     
                    autoFill: true,
                    matchContains: "word",
                    formatItem: function(row) {
                        return row.city + ", " + "<span>" + row.country + "</span>";
                    },
                    formatMatch: function(row) {
                        return row.city;
                    },
                    formatResult: function(row) {
                        return row.city + ", " + row.country;
                    }
            });

A listener for the input

$("#cities").result(function开发者_开发百科(event, data, formatted) {
                    selectedCity = (data.regionID);
            });

And the input:

<input type="text" class="textbox" id="cities" name="q" autocomplete="off">

The trouble is when I reload the page, Internet explorer displays last user Input in the text box. However, the variable has no value.

I have tried with .reset() but no success.

Any ideas why ?


Ok ,, i will answer my own question since i found the solution.

$('#cities').val('');

Thanks everyone !!


It's because most (if not all) of the current generation browsers are so "smart" that they retain form values when you reload a page.

Take a look at this question which is about the same subject, maybe you can use this answer to solve your problem.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜