Domanda

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)?

È stato utile?

Soluzione

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

Altri suggerimenti

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top