【发布时间】:2015-02-03 10:24:31
【问题描述】:
我创建了 Angularjs 指令,将触发器连接到弹出框。一切正常,除非我想在弹出窗口中添加延迟显示。我是 javascript 和 angular js 的新手。因此,我们将不胜感激。
.directive('businessCardPopup', function() {
return {
restrict: "A",
link: function(scope, pop, attrs){
scope.label = attrs.popoverLabel;
$(pop).popover({
trigger: "manual" ,
container: 'body',
template: '<div class="popover" role="tooltip" style="width: 400px;">' +
'<div class="arrow"></div>' +
'<h3 class="popover-title"></h3>' +
'<div class="popover-content">' +
'<div class="data-content"></div>' +
'</div></div>',
html: true,
animation:false,
content: '<div class="col-lg-4"></div>' +
'<div class="col-lg-8"><p>Name</p>' +
'<p>Position</p>' +
'<p>Telephone</p>' +
'<p>Email</p>' +
'<p>Skype | Twitter | LinkedIn</p>' +
'<p>Conversation | View Profile | Follow</p></div> ',
placement: 'top',
delay: {"show": 2000}
})
.on("mouseenter", function () {
var _this = this;
$(this).popover("show");
$(".popover").on("mouseleave", function () {
$(_this).popover('hide');
});
}).on("mouseleave", function () {
var _this = this;
setTimeout(function () {
if (!$(".popover:hover").length) {
$(_this).popover("hide");
}
}, 500);
})
}
}
}
)
【问题讨论】:
标签: javascript angularjs twitter-bootstrap popover