나는 비슷한 필요성이 있었다. 나는 장소 편집 필드를 표시하기 위해 popover를 사용하고 있습니다. 일단 값이 저장되면 popover를 다시 클릭하면 동일한 소스 HTML이 복사되고 이전 값이 선택됩니다. 나는 업데이트와 몇 가지 다른 것들에 대한 가치를 설정하고 놀았으며 아무런 결과도 얻지 못했습니다.
show/hide 이벤트를 트리거하는 대신 수동으로 팝업을 표시하고 숨기는이 솔루션이 등장했습니다.
$(document).on('click', '.ajax-value', function() {
// We only want to init the popover once
if (typeof $(this).data('bs.popover') == "undefined") {
// Init the popover and show immediately
$(this).popover({
'content': $(this).closest('.ajax-edit').find('.ajax-field').html(),
'html': true,
'title': $(this).attr('data-title'),
'placement': 'auto'
}).popover('show');
// Hook into show event and return false so parent does not run
$(this).on('show.bs.popover', function() {
return false;
});
// Same for hide, don't let parent execute
$(this).on('hide.bs.popover', function() {
return false;
});
} else {
// If we already created popover, just toggle hidden class
$(this).closest('.ajax-edit').find('.popover').toggleClass('hidden');
}
});
// This is a custom close button in the popover
$(document).on('click', '.ajax-field-close', function(){
// Just add the hidden class
$(this).closest('.ajax-edit').find('.popover').addClass('hidden');
});
감사합니다.하지만 처음에는 명확하지 않았기 때문에 질문을 업데이트했습니다. 실제로 텍스트가 아닌 HTML을 유지하고 싶습니다. 실제로이 문제는 내 문제가 아니기 때문에 오히려 Popover 내부에로드 된 jquery 플러그인 문제. 나는 당신의 요점을 알아 내지 만, 오해에 대해 고마워하며 미안합니다. – Trufa
@Trufa 알았어, 내 대답에 설명 된대로'.popover ('hide')를 사용하지 않고 popover를 수동으로 숨기거나 표시해야하기 때문에 정말 복잡 할 것이다. popover 함수를 사용하여) popover 위치를 처리합니다 ... – Holt
@Trufa 아마도 트릭을 사용할 수 있습니다 : popover가 숨겨져있을 때 popover에서 다른 곳으로 (복제하지 않고) 내용을 이동 시키므로 요소는 그대로 유지됩니다 ('body'와 같은 것).);), 당신은 그것을 숨기고 popover가 보여지면, 당신은 그 반대의 일을한다. – Holt