件名をリストアップするドロップダウンメニューがあります。私はAJAX呼び出しでこれらのサブジェクトをロードしています。対象が正しくロードされ、メニューが開かれた後になるまで、セレクトメニューを読み込むのに十分速く読み込まれません。これにより、ユーザーはメニューを開き、メニューを閉じてから再び開く必要があります。JS選択ドロップダウンメニューの作成遅延
ドロップダウンメニューを開くときに遅延を発生させ、応答にドロップダウンメニューに入力するのに十分な時間を与えるにはどうすればよいですか?すべての助けをありがとう。
コード:
ドロップダウンメニュー
<div id="subjectForm" class="form-row">
<label>1) Subject Selection:</label>
<select name="subject" id="subjectSelect" class="input-medium">
<option value="0">All</option>
</select>
</div>
AJAXコール
document.getElementById("subjectForm").addEventListener("click", function(event) {
var selectCount = $('#subjectSelect option').size();
if(selectCount == 1) {
$.ajax({
url: '/v2/subjects?',
method: 'GET',
data: {'core': number},
success: function (data) {
// Populates the $subjectSelect filter with subjects
// For each grade brought back from response, add it to the grade filter
$.each(data, function(i, subject){
$('#subjectSelect')
.append($('<option></option>')
.attr("value", subject.id)
.text(subject.title));
});// each
}// success
});// ajax
}// end if
}, false);// #subjectForm clicked
は、 '
タイムアウト後に要素をselectboxにレンダリングするには、setTimeout()を使用します。 – Poria
[あなたのコードはどのようなものですか](http://stackoverflow.com/help/mcve)? – whipdancer