jQueryモーダルダイアログを使用して、ユーザーが選択できるドロップダウンリストを表示しています。ドロップダウンを空のドロップダウンリストに追加することで、ドロップダウンに動的にデータを入力します。これは最初は機能し、2回目はデフォルトのオプションのみを表示し、動的なオプションは表示しませんか?
function showExportDialog() {
//create html string for drop down list
var selectString = "<div><select id=\"selectExport\" style=\"width: 100%\"><option>-- Select Export --</option></select></div>";
//initialize the dialog - register click handler
var $dialog = $(selectString).dialog({
autoOpen: false,
title: 'Export Dialog',
modal: true,
//dims screen to bring dialog to the front
width: 500,
buttons: {
"export": function() {
exportAs($('#selectExport').val());
$(this).dialog('close');
}
}
});
//dynamically generate drop down list based on model type
switch (modelType) {
case "SPATIAL_STATISTICAL":
$('#selectExport').html(''); //clear the drop down list
$("<option value='csv'>CSV (comma separated value)</option>").appendTo("#selectExport");
$("<option value='tab'>TSV (tab separated value)</option>").appendTo("#selectExport");
$("<option value='heat'>Heatmap (google heatmap layer format)</option>").appendTo("#selectExport");
break;
case "STATISTICAL":
break;
case "GRAPH":
break;
case "PATTERN":
break;
default:
throw "Invalid ModelType '" + modelType + "'";
}
//open the dialog
$dialog.dialog('open');
}
これが私の問題を表示するフィドルです:http: //jsfiddle.net/b3v3R/21/
問題を再現するには:
- [エクスポートドロップダウンを表示]をクリックします
- ドロップダウンからオプションを選択します
- [エクスポート]をクリックします
- [エクスポートドロップダウンを表示]をもう一度クリックします
何かご意見は?