Problems, need help? Have a tip or advice? Post it here.
8 posts Page 1 of 1
I would like to run some code after the user has loged out. I tried with using the click event of the logout link, but the code doesn't run. I can get it to work by using preventDefault(), but then, of course, the logout link doesn't work.

Has anybody tried to do this, or maybe even get it working ?
What kind of code you wish to run? Server side (i.e. PHP) or client-side (i.e. JavaScript)?
I would like to run some JS code, e.g. opening a modal window.
The logout option is just a plain link e.g.
Code: Select all
<!-- give an option to logout -->
<a href="<cms:logout_link />">logout</a>

I think you can substitute it for the modal window and invoke the logout link through JS once we're done with the modal.

Of course, my JS skills being what they are, you'll need somebody like @cheesypoof to help you with implementing that in case you need help :)
Ok, thanks. The client said either the modal window or redirecting to home page.
That is my B plan :)
Is this what you want?
Code: Select all
$( ".log-out" ).on( "click", function( event ) {
    event.preventDefault();

    $.ajax({
        url: $( this ).attr( "href" )
    }).done(function() {
        // DO SOMETHING HERE
    });
});
cheesypoof wrote: Is this what you want?
Code: Select all
$( ".log-out" ).on( "click", function( event ) {
    event.preventDefault();

    $.ajax({
        url: $( this ).attr( "href" )
    }).done(function() {
        // DO SOMETHING HERE
    });
});


I already tried something similar. The code gets executed, but the logout doesn't, beacuse of the preventDefault().

I would like to logout, and then run some code after that.

edit: It seems that the logout does work, but not in the same manner as the one without this piece of code.
It doesn't hide the logout link after loging out, like the normal logout would do. Only after visiting other pages, I saw that I was loged out of the website.
Has this been Solved?
Image
where innovation meets technology
8 posts Page 1 of 1