当前位置: 动力学知识库 > 问答 > 编程问答 >

jquery - Dropdown on ajax page shutting

问题描述:

So I have a div that I refresh the contents of every 1 second.

The content being loaded has a dropdown on the page.

The dropdown closes itself every time it refreshes(Expected).

How should I handle this so that the dropdown stays open?

JS

 var isRefreshing = false;

var refreshInterval;

function initRefresh(page, refreshRateMs) {

if (!isRefreshing) {

refreshInterval = setInterval(function () { refreshPage(page) }, refreshRateMs);

isRefreshing = true;

}

}

function refreshPage(page) {

$.get(page, function (data) {

$("#content-wrapper").empty().append(data);

});

}

Page loading

<select id="teamSize" name="teamSize" class="input-xlarge">

<option value="5">

5

</option>

<option value="4">

4

</option>

<option value="3">

3

</option>

<option value="2">

2

</option>

<option value="1">

1

</option>

</select>

<script>

initRefresh('/lobby', 1000);

</script>

网友答案:
  1. Move the div outside the area you are refreshing.
  2. After refreshing simulate a click on the dropbox. This question may help: Can I open a dropdownlist using jQuery
分享给朋友:
您可能感兴趣的文章:
随机阅读: