user3909863
user3909863

Reputation: 401

Anchor tag is not working in fancybox

I want to logout (redirect to the logout page) when I click on "LOGOUT" .

<div id="emailverification" style="display:none;">
<div style="width: 100%;float:left;background-color: #E4E5EA;">

$(document).ready(function () {
    $("#emailverification").fancybox({
        closeClick: false, // prevents closing when clicking INSIDE fancybox 
        openEffect: 'none',
        closeEffect: 'none',
        closeBtn: false,
        keys: {
            close: null
        },
        helpers: {
            overlay: {
                closeClick: false
            }
            // prevents closing when clicking OUTSIDE fancybox 
        }
    }).trigger("click");
});

Check the html code in JSFIDDLE.

Upvotes: 1

Views: 1116

Answers (2)

Spokey
Spokey

Reputation: 10994

Add this after your script. As stated in the comments fancybox is blocking any element from being clicked inside the pop-up. An alternative is to redirect yourself using this script.

$('#emailverification a[href=logout]').click(function (e) {
    location.href = this.href;
});

Upvotes: 0

Amy
Amy

Reputation: 4032

Try this code:

$(document).ready(function() {
            $("#emailverification").fancybox({
             closeClick  : false, // prevents closing when clicking INSIDE fancybox 
             openEffect  : 'none',
             closeEffect : 'none',             
             closeBtn : false,             
//             keys : {
//                close  : null
//             },
             helpers   : { 
              overlay : {closeClick: false} // prevents closing when clicking OUTSIDE fancybox 
             }
            }).trigger("click");
    $('#logout').click(function(){
        window.location="http://www.example.com/";
    })
        });

Upvotes: 1

Related Questions