Welcome Guest, Not a member yet? Register   Sign In
script files not loading in some cases
#1

[eluser]Thyranys[/eluser]
Hi there, I'm pretty new to CodeIgniter and web programming in general, so please bear with me.

If you go to http://test.inthemood.tv and then go to http://test.inthemood.tv/watch/mood_before by clicking on the 'I'm about to watch a movie' button, you'll get something different than when you go to http://test.inthemood.tv/watch/mood_before directly (by copy-pasting it in another tab for example). A div with id '#two' is hidden when you go to the url directly (as it should), whereas when you go through the button it is not hidden.

Apparently my javascript files aren't loading when you go through the button, whereas they are loaded if you go to the url directly.

Does anybody have an idea what's going on? Is CodeIgniter interfering in some way when you go through the button rather than directly?

I'm rather clueless. Thank you for your time. If there's any code that you need, let me know.
#2

[eluser]InsiteFX[/eluser]
use document ready or load your scripts at the bottom of the html code.
#3

[eluser]Thyranys[/eluser]
This is what the script that is not loading looks like:

Code:
$(document).ready(function(){
$('#two').hide();
$('#next-button').click(function(){
  $('#one').hide();
  $('#two').show();
});
});

Don't the scripts always have to be loaded in <head></head>? I'm not entirely sure how you define the 'bottom' of the html code, but if I put the script loading in between the closing </body> and </html> tags, the problem remains the same.
#4

[eluser]InsiteFX[/eluser]
No if they are loaded at the end of the html document it will load faster.

Also if loaded at the top in the head section it may try to set things that
are not yet loaded in the document.
#5

[eluser]Thyranys[/eluser]
Thanks for the help. Hasn't solved the issue yet though Sad.

Any other ideas?
#6

[eluser]InsiteFX[/eluser]
Break your document up into header, content and footer.

Maybe that you are changing pages and the scripts are not there anymore.
Each document should have a header and footer that includes the scripts etc;
#7

[eluser]coolfactor[/eluser]
@Thyranys

There's been some confusing, misleading responses to your question.

I see you're using JavaScript to load the second page at a different URI. Why not combine "mood_before" and "mood_after" into the same page, and have the buttons trigger those modes? Something to do with how jQuery Mobile is designed to work?

Because JavaScript is loading the second page, and not the browser natively, the document.load event doesn't seem to be getting triggered. Try trigging it manually using jQuery after the page loads.




Theme © iAndrew 2016 - Forum software by © MyBB