Question

I have just written my first very basic Jquery Mobile site which has only two pages.

The second page (which could be the first) uses galleria slideshow which has its own js files.

The very strange thing that happened is that if I load page 2 first it runs perfectly fine. However if I run page 1 and then click the link to page 2, it hangs on page 1 and there is a js console error saying that galleria is undefined. I got past the error by including the galleria js files in page 1 and then everything worked fine.

So question is why should I need to do that? Surely these two pages are not connected in any way except the link. Any thoughts / ideas / explanations of this odd behaviour?

Was it helpful?

Solution

This isn't a strange behavior, it's exactly how jQuery Mobile works. In fact, jQM after loaded the first page, load the others using AJAX and simply injecting their body into the first page. If you want to verify this fact, use a DOM inspector. Said that, the <head> section of the others page is never loaded. To solve the problem you've to include the galleria library in each file you use or use something like PHP include (much better).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top