I am making a website, based on node.js, express. I have implemented all my login functionality by passport, and I am easily able to log in or log out by res.user
.
However, I want to implement that when the user is not logged in, and click any link a tooltip should be displayed over my login button to display log in.
Possible methods which I have tried:
I have implemented the first one however tooltip is not showing whatsoever, here is my code for ajax:
$(function () {
$('#selfielogin').click(function (e) {
console.log("alpit");
e.preventDefault();
$.ajax({
url: '/selfie',
type: 'GET',
success: function () {
console.log("*********************");
},
error: function() {
//to show tooltip on login button that you need to login
}
});
})
})
and here is my code where i want my tooltip
<li class="nav-item"> <a id="fblogin" href="/auth/facebook"> <img src="./css/img/fblogin.png" class="img-fluid"> </a> </li>
I am using bootstrap too.
I finally figured it all out by using tippy.js Here is the code:
$(function () {
$('.event').click(function (e) {
e.preventDefault();
$.ajax({
url: '/eventname/selfie',
type: 'GET',
success: function () {
console.log("logged in");
},
error: function () {
var btn = document.querySelector('#fblogin');
tippy(btn, {
size: 'large',
distance: 25
})
btn._tippy.show();
}
});
})
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.