Improve my hack to prevent click on login button when modal is open
-
Hello, and thank you very much for this plugin!
I noticed that the login button for the login modal went a little haywire when I clicked it the second time, So I figured I’d try to disable it when modal dialog was open to prevent this.
I disabled it after click with jQuery .off.The login button action however, when clicked, now used the anchor href link //mysite/wp-login.php instead.
I have quickly made a very ugly fix that does the job. Yet if you have got the time to explain a cleaner solution I would be very happy.
So the fix is to hide your login button and show my login button .login-btn
` function loginHandler(e){
$(e.target).off(‘click’);
$(‘.lwa-links-modal’).trigger(“click”);var loginInterval = setInterval(function(){
if ( $(‘.lwa-modal’).css(‘visibility’) === ‘hidden’ ){
$(‘.login-btn’).on(‘click’, loginHandler);
clearInterval(loginInterval);
unlockModal();
}
},100);
}var isloggedIn = $(‘body’).hasClass(‘logged-in’);
if (!isloggedIn){
$(‘.lwa-links-modal’).hide();
$(‘.login-btn’).show();
$(‘.login-btn’).on(‘click’, loginHandler);
}else{
$(‘.lwa-links-modal’).show();
$(‘.login-btn’).hide();
}
`
Hope I make sense. Thanks again!
- The topic ‘Improve my hack to prevent click on login button when modal is open’ is closed to new replies.