几秒钟后角引导酥料饼皮 [英] angular bootstrap popover hide after few seconds
本文介绍了几秒钟后角引导酥料饼皮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的html code:
This is my html code:
<li class="pop" popover="popover text goes here" popover-trigger="mousedown">
<a><i class="icon-link"></i></a>
</li>
当点击作为预期酥料饼被打开的图标。
Currenly的酥料饼只有通过点击图标关闭。
我祝愿酥料饼的机器会自动几秒钟后关闭。
When clicking the icon a popover is opened as expected. Currenly the popover is close only by click on the icon. I wish that the popover will be closed automaticaly after few seconds.
这是我的javascript code - 不工作:
This is my javascript code - which does not work:
$('.pop').popover().click(function () {
setTimeout(function () {
$('.pop').popover('hide');
}, 4000);
});
运行时
$('.pop').popover()
这是FF调试我越来越:
on FF debugger I getting:
typeError: undefined is not a function
请帮忙:)
推荐答案
有关 @ dfsq的想法启发 tt_isOpen
,你可以创建一个自定义指令做自动隐藏。
Inspired by @dfsq's idea about tt_isOpen
, you could create a custom directive to do the auto hiding.
.directive('popoverAutoclose', function ($timeout) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
var timeoutHandle;
scope.$watch('tt_isOpen', function (isOpen) {
$timeout.cancel(timeoutHandle);
if (isOpen) {
timeoutHandle = $timeout(function () {
scope.tt_isOpen = false;
}, +attrs.popoverAutoclose || 5000);
}
});
}
}
});
和使用这样的:
<li class="pop" popover="popover text goes here" popover-autoclose="2000" popover-trigger="mousedown">
示例Plunker: http://plnkr.co /编辑/ KQKHtz73lFk8Z4g4q6a4?p = preVIEW
这篇关于几秒钟后角引导酥料饼皮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文