$( document ).ready loaded every time


(Stellan) #1

Hi I have a document ready function loaded on scene load for my login scene.
But this function is loaded again when I log out, so if I try to login again, my login api is posted twice.

Any idea how to solve this?

 $( document ).ready(function() {
    var auth = new Auth();
    $('#loginsubmit').click(auth.login.bind(auth));
    $('#int').click(auth.logout.bind(auth));

(Steve Flowers) #2

This might get it:

$( document ).ready(function() {
if{!window.loggedIn || typeof loggedIn == 'undefined'){
    var auth = new Auth();
    $('#loginsubmit').click(auth.login.bind(auth));
    $('#int').click(auth.logout.bind(auth));
    window.loggedIn=true;
}