我創建了Angularjs指令,並將觸發器連接到彈出窗口。除了當我想給popover添加一個延遲顯示時,一切都可以工作。我是新來的JavaScript和角js。所以任何幫助將不勝感激。在鼠標中彈出延遲顯示(Angularjs)
.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);
})
}
}
}
)
請參閱:http://getbootstrap.com/javascript/#popovers-usage。它應該是'show':600. 我也試過 .on('mouseenter',function(){ var _this = this; $(this).delay(5000).popover('show'); 但它似乎沒有延遲popover – 2015-01-15 08:31:39