5

The way JQM loads pages is by getting the element with the attribute data-role="page" via ajax, and not the whole document.

So, how do I make JQuery Mobile load the styles and scripts from any page (or a refresh), rather than only loading them in the entry point (index.htm)?

2 Answers 2

3

Just put them into the BODY tag.

It is described in my other answer: Why I have to put all the script to index.html in jquery mobile

Sign up to request clarification or add additional context in comments.

Comments

0

Thanks, I had all my JS on one file, but the jquery, jqm, and jqm css files needed to be on each page too. What I ended up doing was including a script on each page body that checks if the scripts exist. If they were not there, they would be dynamically added.

It would be like this

    if (document.getElementsByTagName('script') < 3)
    {
     createElement
     setAttribute
     append inside head element
     //repeat for each script / styleshet
    }

    else
     //do nothing 

If I went the route of including all the files in the body, there would be a redundancy of the assets being requested on each page change. I believe this gets around it. It seems to work so far.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.