클리어 될 때까지 부트 스트랩의 popover 내에 사용자의 드롭 다운 선택 사항을 유지해야합니다. 나는 이미 "selected"애트리뷰트를 선택 변경에 따라 동적으로 변경할 수 있고, 그 변경이 HTML select 요소를 대체하도록 만들었다. 나는 모든 것이 작동하고 있다고 생각한다 (나는 경고 기능을 통해 그것을 본다). 불행히도 popover의 "외양"은 아니며, 그렇습니다. 내가 그것을 조사 할 때, 그것은 내가주의 깊게 얻은 것과 일치하지 않습니다.부트 스트랩의 팝 오버에서 드롭 다운 선택을 유지하는 방법은 무엇입니까?
여기 내 피들입니다. 고맙습니다. http://jsfiddle.net/kDmVq/
$(document).on('shown', "#btnPopover", function() {
$('select#optionDropdown').select2({
allowClear: true
}).change('#optionDropdown', function() {
theID = $(this).val();
theSelection = $(this).children('option:selected').text();
$('#selectedID').text(theID);
$('#selectedText').text(theSelection);
$('#optionDropdown option').removeAttr("selected");
$('option[value=' + theID + ']').attr("selected", "selected");
optionDropdownRet = $('#optionDropdown').html();
});
alert($('#optionDropdown').html());
});
$(document).on('hide', "#btnPopover", function() {
alert(optionDropdownRet);
$('options#optionDropdown').replaceWith(optionDropdownRet);
});