twitter-bootstrap 在 onclick 事件中触发 bootstrap popover
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13767946/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Trigger bootstrap popover inside onclick event
提问by Mike
How can i manage to trigger the popover inside the onclick event?
我怎样才能在 onclick 事件中触发弹出框?
jQuery(document).ready(function($) {
$('[rel=popover]').popover().click(function(e) {e.preventDefault()});
});
<button class="btn" rel="popover" data-placement="bottom" data-trigger="manual" data-content="somecontent" data-original-title="Title" type="button" onclick="if(something==true) { console.log($(this));$(this).popover('show'); }">Start</button>
This just gets me an "Uncaught TypeError: undefined is not a function"
这只是让我得到一个“未捕获的类型错误:未定义不是函数”
回答by ?????
Remove your onclick and you can specify the trigger inside of your options according to the docs http://twitter.github.com/bootstrap/javascript.html#popovers
删除您的 onclick,您可以根据文档http://twitter.github.com/bootstrap/javascript.html#popovers在您的选项中指定触发器
$('[rel=popover]').popover({trigger:'click'})
Or specify it inside your html
或者在你的 html 中指定它
<button class="btn" rel="popover" data-placement="bottom" data-trigger="click"

