2014-12-16 2 views
2

부트 스트랩 팝 오버를 사용하고 있습니다. 특정 버튼을 클릭하면 열리고 닫히고 같은 버튼을 클릭하면 다시 닫힙니다.부트 스트랩 팝 오버가 닫히지 않습니다.

제목 옆에 닫기 버튼을 추가하려고했지만 버튼을 클릭했을 때 닫히지 않았습니다.

내 코드 :

$('#emailPopover').popover({ 
     placement:'right', 
     trigger: 'click', 
     html: true, 
     title:'Voter Variables'+ 
      '<button type="button" id="close" class="close" onclick="$(this).popover("hide");">&times;</button>' 
    }); 
+0

'onclick'에서? 확실히'$ ("# emailPopover")'가 아니라면, 단지 JavaScript를'data-'속성을 위해 버리십시오. –

+0

$ ("# emailPopover"). popover ('hide')로도 작동하지 않습니다. – sridhar

+0

ChaoticNadirs에서 제안한대로'"'('this '대신'# emailPopover')을 사용하면 조금 더 자유롭게 따옴표를 중첩 할 수 있습니다. –

답변

2

대신이 같은 인용 부호의 &quot;을 사용해보십시오 :

$('#emailPopover').popover({ 
     placement:'right', 
     trigger: 'click', 
     html: true, 
     title:'Voter Variables'+ 
      '<button type="button" id="close" class="close" onclick="$(&quot;#emailPopover&quot;).popover(&quot;hide&quot;);">&times;</button>' 
    }); 

bootply 예 : http://www.bootply.com/pd2qZayqju

+0

이 팝업을 사용하면 전혀 열리지 않습니다. – sridhar

+0

부트 스트랩 버전에는 문제가 있습니까? 나를 위해 작동 – sridhar

+2

가 –

-1

의도는 경우하여 팝 오버 쇼를하는 경우 사용자가 버튼을 클릭하고 다른 곳을 클릭 할 때 숨기려면 trigger: 'focus' 옵션을 사용해보십시오. Check out the Bootstrap example Dismiss on next click for more details.

당신이 HTML의 버튼에 tabindex="0"를 추가해야합니다

HTML :

<a href="#" tabindex="0" class="btn btn-lg btn-primary" id="emailPopover">Email</a> 

자바 스크립트 : $`의 값 (이)`무엇

$('#emailPopover').popover({ 
    placement:'right', 
    trigger: 'focus', 
    html: true, 
    title:'Voter Variables' 
}); 

JSFiddle

+0

오른쪽 그러나 그는 팝 오버 제목 ... –

+0

$ ('#의 emailPopover') 내부에 작은 닫기 버튼을 추가하려고 팝 오버 ({ 위치 :. '바로', 트리거 : '클릭', HTML : 사실, 을 제목 : '유권자 변수 ' }); HTML : 나는 팝 업 자체 – sridhar

+0

, 당신은 버튼에의 tabindex = "0"을 추가해야합니다. – sridhar

관련 문제