Client side script seems to not work on page change
-
You can add a console.log and see if it is getting triggered at all.
$(window).on('action:ajaxify.end', function(ev, data) { console.log('action:ajaxify.end'); if(ajaxify.data.template.name !== 'login' && ajaxify.data.template.name !== 'register'){ if (!app.user.uid || app.user.uid === 0) { ajaxify.go('login'); } } });
-
So it is always going into the
action:ajaxify.end
handler? Can you try the below and see if it works?$(window).on('action:ajaxify.end', function(ev, data) { console.log('action:ajaxify.end'); if(ajaxify.data.template.name !== 'login' && ajaxify.data.template.name !== 'register'){ if (!app.user.uid || app.user.uid === 0) { $('#content, #footer').removeClass('ajaxifying'); ajaxify.go('login'); } } });
-
@baris This specific function is currently on a mostly blank slate, which makes it more confusing as well. I've tried putting in an console log after each if statement as well and it all goes through. It even goes to the
ajaxify.go('login')
but that just seems to do nothing. -
Hmm, can you try putting some more console.logs in
ajaxify.go
there are some cases where that function will not do anything. For example if there is already an ajaxify in progress it returns early.Maybe you are getting caught by the ajaxify timer which prevents quick ajaxifies. https://github.com/NodeBB/NodeBB/blob/master/public/src/ajaxify.js#L41-L43.
In that case try it on the
develop
branch. Looks like @julian fixed that on that branch https://github.com/NodeBB/NodeBB/commit/b4297cd8f065a94e7de5a3ad4b992e61c9234ca0 -
@baris I copied the the code from the 2nd link into my version of Nodebb and that fixed the issue! Seems like there must've been an already ajaxify in progress which killed
ajaxify.go('login')
Thank you so much! The issue is resolved!
-
-