@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!
@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!
@baris I'll try that! And let you know how it turns out!
@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.
@baris That's curious. Perhaps I messed up while installing Nodebb or something of the like? As it appears to be just me experiencing this issue?
I guess this could be local specific issue, I could try testing this on a test domain and see if it still runs into the same issue.
@baris I am testing locally currently
@baris Hmm, that doesn't seem to do the trick either. It's a real headscratcher. Thank you so much for your time and effort by the way!
@baris It seems to trigger. I get the console. And if I do ('action:ajaxify.end');
It seems to work while getting the alert message as well.
@baris Do you mean where I am adding it? If so, I'm adding to the custom Javascript area in the ACP. Should I add it somewhere else instead?
@baris Oh hmmm, it seems to not happen at all for whatever reason.
@baris I seem to have the same issues. And the browser console seems to come up blank for errors. I've also tested on multiple browsers to see if it was a just a browser specific issue but that doesn't seem to be the case. I actually got a very botched way of making it work currently with the code below.
$(window).on('action:ajaxify.end', function(ev, data) {
if (data.url !== 'login' && data.url !== 'register' && !app.user.uid) {
ajaxify.go('login');
}
setTimeout(function (){
if (data.url !== 'login' && data.url !== 'register' && !app.user.uid) {
ajaxify.go('login');
}
}, 500);
});
I just do the function again after a slight delay and it seems to be working. Which is really odd and not ideal.
I have currently a client side code that redirects users if they are not logged in to the log in page so that non-members can't view the pages. The code is as follows.
$(window).on('action:ajaxify.end', function(ev, data) {
if(data.url !== 'login' && data.url !== 'register'){
if (!app.user.uid || app.user.uid === 0) {
ajaxify.go('login');
}
}
});
The code works on the initial page load, but if I click a different page from the login page like going to the categories page, then it no longer works. I need to refresh the page in order for it to work.
I have noticed that if I put an alert or try debugging it always works. Perhaps this is a dumb question on my part but do you guys have any ideas as to why this is the case and how do I fix it to work on page change as well?